aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/mp3_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:13 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:13 +0200
commit3f55b5a1e42eb6e1d60292bada5697ecf7112feb (patch)
treee128250e87bbbcca9247a1f37a5a214cd268596f /src/inputPlugins/mp3_plugin.c
parentf0bcb4a44a84b1ae4f1f887699a821899ed3b741 (diff)
downloadmpd-3f55b5a1e42eb6e1d60292bada5697ecf7112feb.tar.gz
mpd-3f55b5a1e42eb6e1d60292bada5697ecf7112feb.tar.xz
mpd-3f55b5a1e42eb6e1d60292bada5697ecf7112feb.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.
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/mp3_plugin.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 43be7dc49..cba201817 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;
@@ -871,7 +866,6 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
break;
case MUTEFRAME_SEEK:
if (decoder_seek_where(decoder) <= data->elapsedTime) {
- data->outputPtr = data->outputBuffer;
decoder_clear(decoder);
data->muteFrame = 0;
decoder_command_finished(decoder);
@@ -930,31 +924,27 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
while (i < pcm_length) {
enum decoder_command cmd;
- 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;
cmd = decoder_data(decoder, data->inStream,
data->inStream->seekable,
data->outputBuffer,
- data->outputPtr - data->outputBuffer,
+ 2 * num_samples,
data->elapsedTime,
data->bitRate / 1000,
(replayGainInfo != NULL) ? *replayGainInfo : NULL);
if (cmd == DECODE_COMMAND_STOP)
return DECODE_BREAK;
-
- data->outputPtr = data->outputBuffer;
}
if (data->dropSamplesAtEnd &&
@@ -978,7 +968,6 @@ static int mp3Read(mp3DecodeData * data, struct decoder *decoder,
if (seekMp3InputBuffer(data,
data->frameOffset[j]) ==
0) {
- data->outputPtr = data->outputBuffer;
decoder_clear(decoder);
data->currentFrame = j;
decoder_command_finished(decoder);