Author: anthm Date: Thu Jul 24 19:15:07 2008 New Revision: 9173 Modified: freeswitch/trunk/src/mod/formats/mod_shout/layer3.c freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c Log: omfg Modified: freeswitch/trunk/src/mod/formats/mod_shout/layer3.c ============================================================================== --- freeswitch/trunk/src/mod/formats/mod_shout/layer3.c (original) +++ freeswitch/trunk/src/mod/formats/mod_shout/layer3.c Thu Jul 24 19:15:07 2008 @@ -985,12 +985,15 @@ getbits(mp, 16); /* Dismiss stuffing Bits */ part2remain -= 16; } + if (part2remain > 0) getbits(mp, part2remain); +#if 0 else if (part2remain < 0) { debug_printf("mpg123: %d Can't rewind stream by %d bits!\n", -part2remain, __LINE__); return 1; /* -> error */ } +#endif return 0; } Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c ============================================================================== --- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (original) +++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c Thu Jul 24 19:15:07 2008 @@ -66,6 +66,7 @@ uint8_t shout_init; uint32_t prebuf; int lame_ready; + int eof; }; typedef struct shout_context shout_context_t; @@ -232,11 +233,12 @@ size_t used; size_t lp; size_t rb = 0; - - while (switch_buffer_inuse(context->audio_buffer) < bytes) { + + while (!context->eof && switch_buffer_inuse(context->audio_buffer) < bytes) { lp = sizeof(inbuf); if ((switch_file_read(context->fd, inbuf, &lp) != SWITCH_STATUS_SUCCESS) || lp == 0) { - goto error; + context->eof++; + goto end; } inlen = (int) lp; @@ -253,7 +255,7 @@ do { decode_status = decodeMP3(&context->mp, in, inlen, out, outlen, &dlen); - + if (context->err) { goto error; } @@ -274,22 +276,20 @@ out = context->decode_buf; outlen = sizeof(context->decode_buf); usedlen = 0; + continue; - - } - - if (decode_status == MP3_ERR) { + + } else if (decode_status == MP3_ERR) { if (++context->mp3err >= 5) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Decoder Error!\n"); - goto error; + context->eof++; + goto end; } - - dlen = 0; continue; } context->mp3err = 0; - + usedlen += dlen; out += dlen; outlen -= dlen; @@ -309,16 +309,20 @@ } } + end: + used = switch_buffer_inuse(context->audio_buffer); - if (done || used >= bytes) { - rb = switch_buffer_read(context->audio_buffer, data, used); + if (context->eof || done || used >= bytes) { + if (!(rb = switch_buffer_read(context->audio_buffer, data, bytes))) { + goto error; + } return rb; } return 0; - error: + error: switch_mutex_lock(context->audio_mutex); context->err++; switch_mutex_unlock(context->audio_mutex);