This should address an issue reported by Qball to the dev mailing list: http://sourceforge.net/mailarchive/forum.php?thread_name=48B3CF6F.3090506%40qballcow.nl&forum_name=musicpd-dev-team
The problem was that I wasn't flushing the lame encoder properly. As a result bad data were being propagated through the mp3buf. This was causing problems when the stream was disabled, or re-enabled. --- src/audioOutputs/audioOutput_shout_mp3.c | 39 +++++++++++++++++ +----------- 1 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/audioOutputs/audioOutput_shout_mp3.c b/src/ audioOutputs/audioOutput_shout_mp3.c index da76a21..4ed29d6 100644 --- a/src/audioOutputs/audioOutput_shout_mp3.c +++ b/src/audioOutputs/audioOutput_shout_mp3.c @@ -43,7 +43,7 @@ typedef struct _ShoutData { lame_global_flags *gfp; unsigned char mp3buf[MP3_BUF_SIZE]; - unsigned int mp3buf_full; + int mp3buf_full; float quality; int bitrate; @@ -307,8 +307,8 @@ static void finishEncoder(ShoutData * sd) static int flushEncoder(ShoutData * sd) { - /* Does lame require anything to be done here? */ - return 0; + return ((sd->mp3buf_full = lame_encode_flush(sd->gfp, sd- >mp3buf, + MP3_BUF_SIZE)) > 0); } static void clearEncoder(ShoutData * sd) @@ -320,6 +320,7 @@ static void clearEncoder(ShoutData * sd) } lame_close(sd->gfp); + sd->mp3buf_full = 0; } static void myShoutMp3_closeShoutConn(ShoutData * sd) @@ -406,26 +407,26 @@ static void sendMetadata(ShoutData *sd) static int initEncoder(ShoutData * sd) { - if (NULL == (sd->gfp = lame_init())) { - ERROR("problem setting up lame encoder for shout_mp3\n"); + if (NULL == (sd->gfp = lame_init())) { + ERROR("problem initializing lame encoder for shout_mp3\n"); lame_close(sd->gfp); /* necessary? */ return -1; } if (sd->quality >= -1.0) { if (0 != lame_set_VBR(sd->gfp, vbr_rh)) { - ERROR("problem setting up lame encoder for shout_mp3\n"); + ERROR("problem setting lame encoder VBR mode for shout_mp3\n"); lame_close(sd->gfp); return -1; } if (0 != lame_set_VBR_q(sd->gfp, sd->quality)) { - ERROR("problem setting up lame encoder for shout_mp3\n"); + ERROR("problem setting up lame encoder VBR quality for shout_mp3\n"); lame_close(sd->gfp); return -1; } } else { if (0 != lame_set_brate(sd->gfp, sd->bitrate)) { - ERROR("problem setting up lame encoder for shout_mp3\n"); + ERROR("problem setting up lame encoder bitrate for shout_mp3\n"); lame_close(sd->gfp); return -1; } @@ -433,20 +434,20 @@ static int initEncoder(ShoutData * sd) if (0 != lame_set_num_channels(sd->gfp, sd->audioFormat->channels)) { - ERROR("problem setting up lame encoder for shout\n"); + ERROR("problem setting up lame encoder channels for shout_mp3\n"); lame_close(sd->gfp); return -1; } if (0 != lame_set_in_samplerate(sd->gfp, sd->audioFormat->sampleRate)) { - ERROR("problem setting up lame encoder for shout\n"); + ERROR("problem setting up lame encoder sample rate for shout_mp3\n"); lame_close(sd->gfp); return -1; } if (0 > lame_init_params(sd->gfp)) { - ERROR("problem setting up lame encoder for shout\n"); + ERROR("problem setting up lame encoder for shout_mp3\n"); lame_close(sd->gfp); return -1; } @@ -516,8 +517,9 @@ static int myShoutMp3_openShoutConn(AudioOutput * audioOutput) int status; status = myShoutMp3_connect(sd); - if (status != 0) + if (status != 0) { return status; + } if (initEncoder(sd) < 0) { shout_close(sd->shoutConn); @@ -531,11 +533,14 @@ static int myShoutMp3_openShoutConn(AudioOutput * audioOutput) sd->opened = 1; sd->tagToSend = 0; - while (lame_encode_flush(sd->gfp, sd->mp3buf, sd- >mp3buf_full)) { + if ((sd->mp3buf_full = lame_encode_flush(sd->gfp, sd->mp3buf, + MP3_BUF_SIZE)) >= 0) { if (write_page(sd) < 0) { myShoutMp3_closeShoutConn(sd); return -1; } + } else { + ERROR("error flushing lame encoder\n"); } sd->connAttempts = 0; @@ -571,11 +576,14 @@ static void myShoutMp3_sendMetadata(ShoutData * sd) sendMetadata(sd); - while (lame_encode_flush(sd->gfp, sd->mp3buf, sd- >mp3buf_full)) { + if ((sd->mp3buf_full = lame_encode_flush(sd->gfp, sd->mp3buf, + MP3_BUF_SIZE)) >= 0) { if (write_page(sd) < 0) { myShoutMp3_closeShoutConn(sd); - return -1; + return; } + } else { + ERROR("error flushing lame encoder\n"); } /*if(sd->tag) freeMpdTag(sd->tag); @@ -605,6 +613,7 @@ static int myShoutMp3_play(AudioOutput * audioOutput, if (!sd->opened) { status = myShoutMp3_openShoutConn(audioOutput); if (status < 0) { + ERROR("%s: %s: unable to open shout connection \n", __FILE__, __func__); myShoutMp3_closeDevice(audioOutput); return -1; } else if (status > 0) { -- 1.5.4.3 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team