aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-11-09 03:58:12 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-11-09 03:58:12 +0000
commitc2a238309070d50498971fcddd8f437bba536263 (patch)
treea5da7046d582b44aabab50b6378fcb00e2b43267 /src/audioOutputs
parentfb7de941c3a948ed68915b4ad249831a70d4ff79 (diff)
downloadmpd-c2a238309070d50498971fcddd8f437bba536263.tar.gz
mpd-c2a238309070d50498971fcddd8f437bba536263.tar.xz
mpd-c2a238309070d50498971fcddd8f437bba536263.zip
be sure to flush the metadata on song change
git-svn-id: https://svn.musicpd.org/mpd/trunk@2556 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_shout.c86
1 files changed, 47 insertions, 39 deletions
diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c
index b23210819..2c0cdd898 100644
--- a/src/audioOutputs/audioOutput_shout.c
+++ b/src/audioOutputs/audioOutput_shout.c
@@ -44,6 +44,7 @@ static int shoutInitCount = 0;
typedef struct _ShoutData {
shout_t * shoutConn;
+ int shoutError;
ogg_stream_state os;
ogg_page og;
@@ -251,7 +252,43 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
return 0;
}
-/*static void finishEncoder(ShoutData * sd) {
+static int myShout_handleError(ShoutData * sd, int err) {
+ switch(err) {
+ case SHOUTERR_SUCCESS:
+ break;
+ case SHOUTERR_UNCONNECTED:
+ case SHOUTERR_SOCKET:
+ ERROR("Lost shout connection to %s:%i\n",
+ shout_get_host(sd->shoutConn),
+ shout_get_port(sd->shoutConn));
+ sd->shoutError = 1;
+ return -1;
+ default:
+ ERROR("shout: connection to %s:%i error : %s\n",
+ shout_get_host(sd->shoutConn),
+ shout_get_port(sd->shoutConn),
+ shout_get_error(sd->shoutConn));
+ sd->shoutError = 1;
+ return -1;
+ }
+
+ return 0;
+}
+
+static int write_page(ShoutData * sd) {
+ int err = 0;
+
+ /*DEBUG("shout_delay: %i\n", shout_delay(sd->shoutConn));*/
+ shout_sync(sd->shoutConn);
+ err = shout_send(sd->shoutConn, sd->og.header, sd->og.header_len);
+ if(myShout_handleError(sd, err) < 0) return -1;
+ err = shout_send(sd->shoutConn, sd->og.body, sd->og.body_len);
+ if(myShout_handleError(sd, err) < 0) return -1;
+
+ return 0;
+}
+
+static void finishEncoder(ShoutData * sd) {
vorbis_analysis_wrote(&sd->vd, 0);
while(vorbis_analysis_blockout(&sd->vd, &sd->vb) == 1) {
@@ -263,13 +300,15 @@ static int myShout_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
}
}
-static void flushEncoder(ShoutData * sd) {
- while(1 == ogg_stream_pageout(&sd->os, &sd->og));
-}*/
+static int flushEncoder(ShoutData * sd) {
+ return !(ogg_stream_pageout(&sd->os, &sd->og) <= 0 );
+}
static void clearEncoder(ShoutData * sd) {
- /*finishEncoder(sd);
- flushEncoder(sd);*/
+ finishEncoder(sd);
+ while(1 == flushEncoder(sd)) {
+ if(!sd->shoutError) write_page(sd);
+ }
vorbis_comment_clear(&sd->vc);
ogg_stream_clear(&sd->os);
@@ -311,39 +350,6 @@ static void myShout_closeDevice(AudioOutput * audioOutput) {
audioOutput->open = 0;
}
-static int myShout_handleError(ShoutData * sd, int err) {
- switch(err) {
- case SHOUTERR_SUCCESS:
- break;
- case SHOUTERR_UNCONNECTED:
- case SHOUTERR_SOCKET:
- ERROR("Lost shout connection to %s:%i\n",
- shout_get_host(sd->shoutConn),
- shout_get_port(sd->shoutConn));
- return -1;
- default:
- ERROR("shout: connection to %s:%i error : %s\n",
- shout_get_host(sd->shoutConn),
- shout_get_port(sd->shoutConn),
- shout_get_error(sd->shoutConn));
- return -1;
- }
-
- return 0;
-}
-
-static int write_page(ShoutData * sd) {
- int err = 0;
-
- shout_sync(sd->shoutConn);
- err = shout_send(sd->shoutConn, sd->og.header, sd->og.header_len);
- if(myShout_handleError(sd, err) < 0) return -1;
- err = shout_send(sd->shoutConn, sd->og.body, sd->og.body_len);
- if(myShout_handleError(sd, err) < 0) return -1;
-
- return 0;
-}
-
#define addTag(name, value) { \
if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
}
@@ -420,6 +426,8 @@ static int myShout_openShoutConn(AudioOutput * audioOutput) {
return -1;
}
+ sd->shoutError = 0;
+
copyTagToVorbisComment(sd);
vorbis_analysis_headerout(&(sd->vd), &(sd->vc), &(sd->header_main),