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
This commit is contained in:
Eric Wong 2006-10-11 00:18:43 +00:00
parent 5694984c98
commit 5a3f501fc8

View File

@ -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),