aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2007-06-12 18:28:57 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2007-06-12 18:28:57 +0000
commit6f2be4727064bf96c9cfa4622c144566b8c7d7cf (patch)
tree8e7ce3e29515eeab8c8be2c8208f3da3eec9159e
parent3c5cecb828cdf9618cd4ec14a15f8cc59e313db8 (diff)
downloadmpd-6f2be4727064bf96c9cfa4622c144566b8c7d7cf.tar.gz
mpd-6f2be4727064bf96c9cfa4622c144566b8c7d7cf.tar.xz
mpd-6f2be4727064bf96c9cfa4622c144566b8c7d7cf.zip
Make the shout timeout configurable. The default is still 2 seconds.
git-svn-id: https://svn.musicpd.org/mpd/trunk@6556 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--doc/mpd.conf.54
-rw-r--r--doc/mpdconf.example1
-rw-r--r--src/audioOutputs/audioOutput_shout.c15
3 files changed, 18 insertions, 2 deletions
diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5
index d52f07200..7db2eee05 100644
--- a/doc/mpd.conf.5
+++ b/doc/mpd.conf.5
@@ -375,6 +375,10 @@ default is "source".
This specifies whether to request that the stream be listed in all public
stream directories that the icecast server knows about. The default is no.
.TP
+.B timeout <seconds>
+This specifies the number of seconds to wait before giving up on trying to
+connect to the icecast server. The default is 2 seconds.
+.TP
.B description <description>
This specifies a description of the stream.
.TP
diff --git a/doc/mpdconf.example b/doc/mpdconf.example
index bddc4d482..be04adb91 100644
--- a/doc/mpdconf.example
+++ b/doc/mpdconf.example
@@ -124,6 +124,7 @@ error_file "~/.mpd/mpd.error"
# description "My Stream Description" # optional
# genre "jazz" # optional
# public "no" # optional
+# timeout "2" # optional
#}
#
# An example of a null output (for no audio output):
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c
index 41e19a450..5444912c5 100644
--- a/src/audioOutputs/audioOutput_shout.c
+++ b/src/audioOutputs/audioOutput_shout.c
@@ -33,7 +33,7 @@
#include <vorbis/vorbisenc.h>
#define CONN_ATTEMPT_INTERVAL 60
-#define CONN_TIMEOUT 2
+#define DEFAULT_CONN_TIMEOUT 2
static int shoutInitCount;
@@ -63,6 +63,7 @@ typedef struct _ShoutData {
MpdTag *tag;
int tagToSend;
+ int timeout;
int connAttempts;
time_t lastAttempt;
@@ -80,6 +81,7 @@ static ShoutData *newShoutData(void)
ret->tagToSend = 0;
ret->bitrate = -1;
ret->quality = -2.0;
+ ret->timeout = DEFAULT_CONN_TIMEOUT;
ret->connAttempts = 0;
ret->lastAttempt = 0;
ret->audioFormat = NULL;
@@ -221,6 +223,15 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param)
}
/* optional paramters */
+ blockParam = getBlockParam(param, "timeout");
+ if (blockParam) {
+ sd->timeout = strtod(blockParam->value, &test);
+ if (*test != '\0' || sd->timeout <= 0) {
+ FATAL("shout timeout is not a positive integer, "
+ "line %i\n", blockParam->line);
+ }
+ }
+
blockParam = getBlockParam(param, "genre");
if (blockParam && shout_set_genre(sd->shoutConn, blockParam->value)) {
FATAL("error configuring shout defined at line %i: %s\n",
@@ -451,7 +462,7 @@ static int myShout_openShoutConn(AudioOutput * audioOutput)
state = shout_open(sd->shoutConn);
- while (state == SHOUTERR_BUSY && (t - sd->lastAttempt) < CONN_TIMEOUT) {
+ while (state == SHOUTERR_BUSY && (t - sd->lastAttempt) < sd->timeout) {
my_usleep(10000);
state = shout_get_connected(sd->shoutConn);
t = time(NULL);