diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-10-11 00:18:43 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-10-11 00:18:43 +0000 |
commit | 5a3f501fc8f32326bda6a3b8c7cf0b98ea108108 (patch) | |
tree | 5df375e79ba3efd24f448b272931b217d70db92e /src/audioOutputs/audioOutput_shout.c | |
parent | 5694984c985e47e53e94ade2470b168fb660f176 (diff) | |
download | mpd-5a3f501fc8f32326bda6a3b8c7cf0b98ea108108.tar.gz mpd-5a3f501fc8f32326bda6a3b8c7cf0b98ea108108.tar.xz mpd-5a3f501fc8f32326bda6a3b8c7cf0b98ea108108.zip |
audioOutput_shout: use shout_set_nonblocking
This patch should continue to allow mpd to play as well as
possible to icecast servers while avoiding stalls on local
devices. This has eliminated ALSA underrun errors
for me while streaming to a remote host while the network
connection was bad.
Of course, this makes opening a connection non-blocking, too,
so myShout_openShoutConn is a bit more complex.
git-svn-id: https://svn.musicpd.org/mpd/trunk@4898 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/audioOutputs/audioOutput_shout.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 8aa911ae4..1cc560ad3 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -67,6 +67,7 @@ typedef struct _ShoutData { int connAttempts; time_t lastAttempt; + int last_err; /* just a pointer to audioOutput->outAudioFormat */ AudioFormat *audioFormat; @@ -85,6 +86,7 @@ static ShoutData *newShoutData(void) ret->connAttempts = 0; ret->lastAttempt = 0; ret->audioFormat = NULL; + ret->last_err = SHOUTERR_UNCONNECTED; return ret; } @@ -220,6 +222,7 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param) shout_set_name(sd->shoutConn, name) != SHOUTERR_SUCCESS || shout_set_user(sd->shoutConn, user) != SHOUTERR_SUCCESS || shout_set_public(sd->shoutConn, public) != SHOUTERR_SUCCESS || + shout_set_nonblocking(sd->shoutConn, 1) != SHOUTERR_SUCCESS || shout_set_format(sd->shoutConn, SHOUT_FORMAT_VORBIS) != SHOUTERR_SUCCESS || shout_set_protocol(sd->shoutConn, SHOUT_PROTOCOL_HTTP) @@ -358,6 +361,7 @@ static void myShout_closeShoutConn(ShoutData * sd) } } + sd->last_err = SHOUTERR_UNCONNECTED; sd->opened = 0; } @@ -460,9 +464,19 @@ static int myShout_openShoutConn(AudioOutput * audioOutput) sd->connAttempts++; - sd->lastAttempt = t; - - if (shout_open(sd->shoutConn) != SHOUTERR_SUCCESS) { + if (sd->last_err == SHOUTERR_UNCONNECTED) + sd->last_err = shout_open(sd->shoutConn); + switch (sd->last_err) { + case SHOUTERR_SUCCESS: + case SHOUTERR_CONNECTED: + break; + case SHOUTERR_BUSY: + sd->last_err = shout_get_connected(sd->shoutConn); + if (sd->last_err == SHOUTERR_CONNECTED) + break; + return -1; + default: + sd->lastAttempt = t; ERROR("problem opening connection to shout server %s:%i " "(attempt %i): %s\n", shout_get_host(sd->shoutConn), |