Commit 5a3f501f authored by Eric Wong's avatar Eric Wong

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
parent 5694984c
...@@ -67,6 +67,7 @@ typedef struct _ShoutData { ...@@ -67,6 +67,7 @@ typedef struct _ShoutData {
int connAttempts; int connAttempts;
time_t lastAttempt; time_t lastAttempt;
int last_err;
/* just a pointer to audioOutput->outAudioFormat */ /* just a pointer to audioOutput->outAudioFormat */
AudioFormat *audioFormat; AudioFormat *audioFormat;
...@@ -85,6 +86,7 @@ static ShoutData *newShoutData(void) ...@@ -85,6 +86,7 @@ static ShoutData *newShoutData(void)
ret->connAttempts = 0; ret->connAttempts = 0;
ret->lastAttempt = 0; ret->lastAttempt = 0;
ret->audioFormat = NULL; ret->audioFormat = NULL;
ret->last_err = SHOUTERR_UNCONNECTED;
return ret; return ret;
} }
...@@ -220,6 +222,7 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param) ...@@ -220,6 +222,7 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
shout_set_name(sd->shoutConn, name) != SHOUTERR_SUCCESS || shout_set_name(sd->shoutConn, name) != SHOUTERR_SUCCESS ||
shout_set_user(sd->shoutConn, user) != SHOUTERR_SUCCESS || shout_set_user(sd->shoutConn, user) != SHOUTERR_SUCCESS ||
shout_set_public(sd->shoutConn, public) != 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) shout_set_format(sd->shoutConn, SHOUT_FORMAT_VORBIS)
!= SHOUTERR_SUCCESS || != SHOUTERR_SUCCESS ||
shout_set_protocol(sd->shoutConn, SHOUT_PROTOCOL_HTTP) shout_set_protocol(sd->shoutConn, SHOUT_PROTOCOL_HTTP)
...@@ -358,6 +361,7 @@ static void myShout_closeShoutConn(ShoutData * sd) ...@@ -358,6 +361,7 @@ static void myShout_closeShoutConn(ShoutData * sd)
} }
} }
sd->last_err = SHOUTERR_UNCONNECTED;
sd->opened = 0; sd->opened = 0;
} }
...@@ -460,9 +464,19 @@ static int myShout_openShoutConn(AudioOutput * audioOutput) ...@@ -460,9 +464,19 @@ static int myShout_openShoutConn(AudioOutput * audioOutput)
sd->connAttempts++; sd->connAttempts++;
sd->lastAttempt = t; if (sd->last_err == SHOUTERR_UNCONNECTED)
sd->last_err = shout_open(sd->shoutConn);
if (shout_open(sd->shoutConn) != SHOUTERR_SUCCESS) { 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 " ERROR("problem opening connection to shout server %s:%i "
"(attempt %i): %s\n", "(attempt %i): %s\n",
shout_get_host(sd->shoutConn), shout_get_host(sd->shoutConn),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment