Commit f0bcb4a4 authored by Max Kellermann's avatar Max Kellermann

mp3: don't do a second flush in mp3_decode()

The previous patch made mp3Read() flush the output buffer in every iteration, which means we can eliminate the flush check after invoking mp3Read().
parent 2e8bd3ae
...@@ -168,7 +168,6 @@ typedef struct _mp3DecodeData { ...@@ -168,7 +168,6 @@ typedef struct _mp3DecodeData {
int foundXing; int foundXing;
int foundFirstFrame; int foundFirstFrame;
int decodedFirstFrame; int decodedFirstFrame;
int flush;
unsigned long bitRate; unsigned long bitRate;
InputStream *inStream; InputStream *inStream;
struct audio_dither dither; struct audio_dither dither;
...@@ -193,7 +192,6 @@ static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) ...@@ -193,7 +192,6 @@ static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream)
data->foundXing = 0; data->foundXing = 0;
data->foundFirstFrame = 0; data->foundFirstFrame = 0;
data->decodedFirstFrame = 0; data->decodedFirstFrame = 0;
data->flush = 1;
data->inStream = inStream; data->inStream = inStream;
data->layer = 0; data->layer = 0;
memset(&(data->dither), 0, sizeof(struct audio_dither)); memset(&(data->dither), 0, sizeof(struct audio_dither));
...@@ -421,7 +419,6 @@ static int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag, ...@@ -421,7 +419,6 @@ static int decodeNextFrameHeader(mp3DecodeData * data, MpdTag ** tag,
ERROR("unrecoverable frame level error " ERROR("unrecoverable frame level error "
"(%s).\n", "(%s).\n",
mad_stream_errorstr(&data->stream)); mad_stream_errorstr(&data->stream));
data->flush = 0;
return DECODE_BREAK; return DECODE_BREAK;
} }
} }
...@@ -474,7 +471,6 @@ static int decodeNextFrame(mp3DecodeData * data) ...@@ -474,7 +471,6 @@ static int decodeNextFrame(mp3DecodeData * data)
ERROR("unrecoverable frame level error " ERROR("unrecoverable frame level error "
"(%s).\n", "(%s).\n",
mad_stream_errorstr(&data->stream)); mad_stream_errorstr(&data->stream));
data->flush = 0;
return DECODE_BREAK; return DECODE_BREAK;
} }
} }
...@@ -955,10 +951,8 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -955,10 +951,8 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
data->elapsedTime, data->elapsedTime,
data->bitRate / 1000, data->bitRate / 1000,
(replayGainInfo != NULL) ? *replayGainInfo : NULL); (replayGainInfo != NULL) ? *replayGainInfo : NULL);
if (cmd == DECODE_COMMAND_STOP) { if (cmd == DECODE_COMMAND_STOP)
data->flush = 0;
return DECODE_BREAK; return DECODE_BREAK;
}
data->outputPtr = data->outputBuffer; data->outputPtr = data->outputBuffer;
} }
...@@ -1080,16 +1074,6 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream) ...@@ -1080,16 +1074,6 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
decoder_initialized(decoder, &audio_format, data.totalTime); decoder_initialized(decoder, &audio_format, data.totalTime);
while (mp3Read(&data, decoder, &replayGainInfo) != DECODE_BREAK) ; while (mp3Read(&data, decoder, &replayGainInfo) != DECODE_BREAK) ;
/* send last little bit if not DECODE_COMMAND_STOP */
if (decoder_get_command(decoder) != DECODE_COMMAND_STOP &&
data.outputPtr != data.outputBuffer && data.flush) {
decoder_data(decoder, NULL,
data.inStream->seekable,
data.outputBuffer,
data.outputPtr - data.outputBuffer,
data.elapsedTime, data.bitRate / 1000,
replayGainInfo);
}
if (replayGainInfo) if (replayGainInfo)
freeReplayGainInfo(replayGainInfo); freeReplayGainInfo(replayGainInfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment