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
This commit is contained in:
parent
82cb5e0931
commit
2c9b50cabd
@ -30,11 +30,14 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include <shout/shout.h>
|
#include <shout/shout.h>
|
||||||
#include <vorbis/vorbisenc.h>
|
#include <vorbis/vorbisenc.h>
|
||||||
#include <vorbis/codec.h>
|
#include <vorbis/codec.h>
|
||||||
|
|
||||||
|
#define CONN_ATTEMPT_INTERVAL 60
|
||||||
|
|
||||||
static int shoutInitCount = 0;
|
static int shoutInitCount = 0;
|
||||||
|
|
||||||
/* lots of this code blatantly stolent from bossogg/bossao2 */
|
/* lots of this code blatantly stolent from bossogg/bossao2 */
|
||||||
@ -68,6 +71,9 @@ typedef struct _ShoutData {
|
|||||||
|
|
||||||
MpdTag * tag;
|
MpdTag * tag;
|
||||||
int tagToSend;
|
int tagToSend;
|
||||||
|
|
||||||
|
int connAttempts;
|
||||||
|
time_t lastAttempt;
|
||||||
} ShoutData;
|
} ShoutData;
|
||||||
|
|
||||||
static ShoutData * newShoutData() {
|
static ShoutData * newShoutData() {
|
||||||
@ -81,6 +87,8 @@ static ShoutData * newShoutData() {
|
|||||||
ret->tagToSend = 0;
|
ret->tagToSend = 0;
|
||||||
ret->bitrate = -1;
|
ret->bitrate = -1;
|
||||||
ret->quality = -1.0;
|
ret->quality = -1.0;
|
||||||
|
ret->connAttempts = 0;
|
||||||
|
ret->lastAttempt = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -370,12 +378,20 @@ static int initEncoder(ShoutData * sd) {
|
|||||||
|
|
||||||
static int myShout_openShoutConn(AudioOutput * audioOutput) {
|
static int myShout_openShoutConn(AudioOutput * audioOutput) {
|
||||||
ShoutData * sd = (ShoutData *)audioOutput->data;
|
ShoutData * sd = (ShoutData *)audioOutput->data;
|
||||||
|
time_t t = time(NULL);
|
||||||
|
|
||||||
if(shout_open(sd->shoutConn) != SHOUTERR_SUCCESS)
|
sd->connAttempts++;
|
||||||
{
|
|
||||||
ERROR("problem opening connection to shout server: %s\n",
|
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));
|
shout_get_error(sd->shoutConn));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,8 +420,7 @@ static int myShout_openShoutConn(AudioOutput * audioOutput) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(sd->tag) freeMpdTag(sd->tag);
|
sd->connAttempts = 0;
|
||||||
sd->tag = NULL;*/
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user