Commit 2e8bd3ae authored by Max Kellermann's avatar Max Kellermann

mp3: always flush directly after decoding/dithering

Since we try to fill the buffer in every iteration, we assume that we should flush the output buffer at the end of each iteration.
parent af83ac5e
...@@ -933,6 +933,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -933,6 +933,7 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
} }
while (i < pcm_length) { while (i < pcm_length) {
enum decoder_command cmd;
unsigned int num_samples = unsigned int num_samples =
(data->outputBufferEnd - data->outputPtr) / (data->outputBufferEnd - data->outputPtr) /
(2 * MAD_NCHANNELS(&(data->frame).header)); (2 * MAD_NCHANNELS(&(data->frame).header));
...@@ -947,22 +948,19 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder, ...@@ -947,22 +948,19 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
MAD_NCHANNELS(&(data->frame).header)); MAD_NCHANNELS(&(data->frame).header));
data->outputPtr += 2 * num_samples; data->outputPtr += 2 * num_samples;
if (data->outputPtr >= data->outputBufferEnd) { cmd = decoder_data(decoder, data->inStream,
enum decoder_command cmd; data->inStream->seekable,
cmd = decoder_data(decoder, data->inStream, data->outputBuffer,
data->inStream->seekable, data->outputPtr - data->outputBuffer,
data->outputBuffer, data->elapsedTime,
data->outputPtr - data->outputBuffer, data->bitRate / 1000,
data->elapsedTime, (replayGainInfo != NULL) ? *replayGainInfo : NULL);
data->bitRate / 1000, if (cmd == DECODE_COMMAND_STOP) {
(replayGainInfo != NULL) ? *replayGainInfo : NULL); data->flush = 0;
if (cmd == DECODE_COMMAND_STOP) { return DECODE_BREAK;
data->flush = 0;
return DECODE_BREAK;
}
data->outputPtr = data->outputBuffer;
} }
data->outputPtr = data->outputBuffer;
} }
if (data->dropSamplesAtEnd && if (data->dropSamplesAtEnd &&
......
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