diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2006-08-13 02:53:20 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2006-08-13 02:53:20 +0000 |
commit | 66512edb6caaffa78727bfd43b0dbe540d06ce21 (patch) | |
tree | 5f6abe9da7283997e763a127372be6ab70efe7b2 /src/inputPlugins | |
parent | 0511e14db09698c9665a2c8fe299235f1242d9ea (diff) |
Presume that the Xing frame count is accurate, and stop decoding when we hit the last frame
git-svn-id: https://svn.musicpd.org/mpd/trunk@4618 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugins')
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 29a0c43d9..6211ce085 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -138,6 +138,7 @@ typedef struct _mp3DecodeData { int dropFramesAtEnd; int dropSamplesAtStart; int dropSamplesAtEnd; + int foundXing; int foundFirstFrame; int decodedFirstFrame; int flush; @@ -161,6 +162,7 @@ static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) data->dropFramesAtEnd = 0; data->dropSamplesAtStart = 0; data->dropSamplesAtEnd = 0; + data->foundXing = 0; data->foundFirstFrame = 0; data->decodedFirstFrame = 0; data->flush = 1; @@ -640,6 +642,7 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, bitlen = data->stream.anc_bitlen; if (parse_xing(&xing, &ptr, &bitlen)) { + data->foundXing = 1; data->muteFrame = MUTEFRAME_SKIP; if (parse_lame(&lame, &ptr, &bitlen)) { @@ -737,9 +740,12 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, mad_timer_add(&data->timer, (data->frame).header.duration); data->bitRate = (data->frame).header.bitrate; if (data->currentFrame >= data->maxFrames) { + /* stop decoding, since Xing maxFrames is accurate */ + if (data->foundXing) return DECODE_BREAK; data->currentFrame = data->maxFrames - 1; - } else + } else { data->highestFrame++; + } data->frameOffset[data->currentFrame] = data->inStream->offset; if (data->stream.this_frame != NULL) { data->frameOffset[data->currentFrame] -= @@ -749,8 +755,9 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, data->stream.bufend - data->stream.buffer; } data->times[data->currentFrame] = data->timer; - } else + } else { data->timer = data->times[data->currentFrame]; + } data->currentFrame++; data->elapsedTime = ((float)mad_timer_count(data->timer, MAD_UNITS_MILLISECONDS)) / |