aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:13 +0200
committerEric Wong <normalperson@yhbt.net>2008-08-30 19:44:08 -0700
commit66ecc1901ad51a1c8a54064fd5ac33454a7cd4b2 (patch)
treee0fcb4844a690b44298b4bae975b73cd127b9d84
parentc9c9a7c7742afa59990cd1a3f1d52d2ab8c486d1 (diff)
downloadmpd-66ecc1901ad51a1c8a54064fd5ac33454a7cd4b2.tar.gz
mpd-66ecc1901ad51a1c8a54064fd5ac33454a7cd4b2.tar.xz
mpd-66ecc1901ad51a1c8a54064fd5ac33454a7cd4b2.zip
mp3: eliminated outputPtr
The output buffer is always flushed after being appended to, which allows us to assume it is always empty. Always start writing at outputBuffer, don't remember outputPtr.
-rw-r--r--src/inputPlugins/mp3_plugin.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 5e217c6ee..16770e63f 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -151,8 +151,6 @@ typedef struct _mp3DecodeData {
mad_timer_t timer;
unsigned char readBuffer[READ_BUFFER_SIZE];
char outputBuffer[MP3_DATA_OUTPUT_BUFFER_SIZE];
- char *outputPtr;
- char *outputBufferEnd;
float totalTime;
float elapsedTime;
int muteFrame;
@@ -176,9 +174,6 @@ typedef struct _mp3DecodeData {
static void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream)
{
- data->outputPtr = data->outputBuffer;
- data->outputBufferEnd =
- data->outputBuffer + MP3_DATA_OUTPUT_BUFFER_SIZE;
data->muteFrame = 0;
data->highestFrame = 0;
data->maxFrames = 0;
@@ -844,12 +839,10 @@ static void mp3Read_seek(mp3DecodeData * data)
j++;
if (j < data->highestFrame) {
dc_action_begin();
- if (seekMp3InputBuffer(data, data->frameOffset[j]) < 0) {
+ if (seekMp3InputBuffer(data, data->frameOffset[j]) < 0)
dc.seek_where = DC_SEEK_ERROR;
- } else {
- data->outputPtr = data->outputBuffer;
+ else
data->currentFrame = j;
- }
data->muteFrame = 0;
dc_action_end();
}
@@ -897,7 +890,6 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
if (dc.seek_where <= data->elapsedTime) {
dc_action_begin();
assert(dc.action == DC_ACTION_SEEK);
- data->outputPtr = data->outputBuffer;
data->muteFrame = 0;
dc_action_end();
}
@@ -955,29 +947,29 @@ static int mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
while (i < pcm_length) {
enum dc_action action;
- unsigned int num_samples =
- (data->outputBufferEnd - data->outputPtr) /
+ unsigned int num_samples = sizeof(data->outputBuffer) /
(2 * MAD_NCHANNELS(&(data->frame).header));
+
if (num_samples > pcm_length - i)
num_samples = pcm_length - i;
i += num_samples;
- num_samples = dither_buffer((mpd_sint16 *) data->outputPtr,
+ num_samples = dither_buffer((mpd_sint16 *)
+ data->outputBuffer,
&data->synth, &data->dither,
i - num_samples, i,
- MAD_NCHANNELS(&(data->frame).header));
- data->outputPtr += 2 * num_samples;
+ MAD_NCHANNELS(
+ &(data->frame).header));
action = ob_send(data->outputBuffer,
- data->outputPtr - data->outputBuffer,
+ 2 * num_samples,
data->elapsedTime,
data->bitRate / 1000,
replayGainInfo ? *replayGainInfo : NULL);
if (action == DC_ACTION_STOP)
return DECODE_BREAK;
- data->outputPtr = data->outputBuffer;
if (action == DC_ACTION_SEEK)
break;