aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-11-02 13:26:50 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-11-02 13:26:50 +0000
commit2c9b50cabd5563b0c81ca7cf4893b5ea08c6bc92 (patch)
tree331f90a7fad80d6e970780da734f37e605e3b8d0 /src/audioOutputs
parent82cb5e0931fb0ab25715be10c96110d4b9e3e482 (diff)
downloadmpd-2c9b50cabd5563b0c81ca7cf4893b5ea08c6bc92.tar.gz
mpd-2c9b50cabd5563b0c81ca7cf4893b5ea08c6bc92.tar.xz
mpd-2c9b50cabd5563b0c81ca7cf4893b5ea08c6bc92.zip
only attempt to reconnect to shout server every 60 seconds
git-svn-id: https://svn.musicpd.org/mpd/trunk@2472 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs')
-rw-r--r--src/audioOutputs/audioOutput_shout.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c
index 8b8e789fb..82c793c99 100644
--- a/src/audioOutputs/audioOutput_shout.c
+++ b/src/audioOutputs/audioOutput_shout.c
@@ -30,11 +30,14 @@
#include <string.h>
#include <assert.h>
#include <signal.h>
+#include <time.h>
#include <shout/shout.h>
#include <vorbis/vorbisenc.h>
#include <vorbis/codec.h>
+#define CONN_ATTEMPT_INTERVAL 60
+
static int shoutInitCount = 0;
/* lots of this code blatantly stolent from bossogg/bossao2 */
@@ -68,6 +71,9 @@ typedef struct _ShoutData {
MpdTag * tag;
int tagToSend;
+
+ int connAttempts;
+ time_t lastAttempt;
} ShoutData;
static ShoutData * newShoutData() {
@@ -81,6 +87,8 @@ static ShoutData * newShoutData() {
ret->tagToSend = 0;
ret->bitrate = -1;
ret->quality = -1.0;
+ ret->connAttempts = 0;
+ ret->lastAttempt = 0;
return ret;
}
@@ -370,12 +378,20 @@ static int initEncoder(ShoutData * sd) {
static int myShout_openShoutConn(AudioOutput * audioOutput) {
ShoutData * sd = (ShoutData *)audioOutput->data;
+ time_t t = time(NULL);
- if(shout_open(sd->shoutConn) != SHOUTERR_SUCCESS)
- {
- ERROR("problem opening connection to shout server: %s\n",
- shout_get_error(sd->shoutConn));
+ sd->connAttempts++;
+ if(t - sd->lastAttempt < CONN_ATTEMPT_INTERVAL) {
+ return -1;
+ }
+
+ sd->lastAttempt = t;
+
+ if(shout_open(sd->shoutConn) != SHOUTERR_SUCCESS) {
+ ERROR("problem opening connection to shout server (attempt %i):"
+ " %s\n", sd->connAttempts,
+ shout_get_error(sd->shoutConn));
return -1;
}
@@ -404,8 +420,7 @@ static int myShout_openShoutConn(AudioOutput * audioOutput) {
}
}
- /*if(sd->tag) freeMpdTag(sd->tag);
- sd->tag = NULL;*/
+ sd->connAttempts = 0;
return 0;
}