aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:12 +0200
committerEric Wong <normalperson@yhbt.net>2008-08-30 19:37:30 -0700
commitb40e8194e8e7ff816ca225ddedf5b546c8ecae96 (patch)
tree15bfbcd8b1b45c3050c0acc6609021bcf29a028c
parent33b39572ddff251333d92e174d304adb6b2d3b83 (diff)
downloadmpd-b40e8194e8e7ff816ca225ddedf5b546c8ecae96.tar.gz
mpd-b40e8194e8e7ff816ca225ddedf5b546c8ecae96.tar.xz
mpd-b40e8194e8e7ff816ca225ddedf5b546c8ecae96.zip
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.
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/mp3_plugin.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 2bdff4bd4..c9de49290 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -958,6 +958,7 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
}
while (i < pcm_length) {
+ enum dc_action action;
unsigned int num_samples =
(data->outputBufferEnd - data->outputPtr) /
(2 * MAD_NCHANNELS(&(data->frame).header));
@@ -972,25 +973,20 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
MAD_NCHANNELS(&(data->frame).header));
data->outputPtr += 2 * num_samples;
- if (data->outputPtr >= data->outputBufferEnd) {
- enum dc_action action = ob_send(
- data->outputBuffer,
- data->outputPtr -
- data->outputBuffer,
- data->elapsedTime,
- data->bitRate / 1000,
- replayGainInfo ? *replayGainInfo
- : NULL);
-
- if (action == DC_ACTION_STOP) {
- data->flush = 0;
- return DECODE_BREAK;
- }
- data->outputPtr = data->outputBuffer;
+ action = ob_send(data->outputBuffer,
+ data->outputPtr - data->outputBuffer,
+ data->elapsedTime,
+ data->bitRate / 1000,
+ replayGainInfo ? *replayGainInfo : NULL);
- if (action == DC_ACTION_SEEK)
- break;
+ if (action == DC_ACTION_STOP) {
+ data->flush = 0;
+ return DECODE_BREAK;
}
+ data->outputPtr = data->outputBuffer;
+
+ if (action == DC_ACTION_SEEK)
+ break;
}
if (data->dropSamplesAtEnd &&