diff options
author | Max Kellermann <max@duempel.org> | 2008-11-12 08:29:40 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-12 08:29:40 +0100 |
commit | 432da18e44aaf5f6c62d50a033cb6fe0a9bea148 (patch) | |
tree | 9d2d414681730ca5e3974c8edca0ee498dd0c98e /src/decoder/aac_plugin.c | |
parent | 487e05c67dae84e15cf09b1dd9d2f9fad55a262a (diff) | |
download | mpd-432da18e44aaf5f6c62d50a033cb6fe0a9bea148.tar.gz mpd-432da18e44aaf5f6c62d50a033cb6fe0a9bea148.tar.xz mpd-432da18e44aaf5f6c62d50a033cb6fe0a9bea148.zip |
aac: make the input buffer static
Allocate the input buffer within the AacBuffer struct.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/aac_plugin.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/decoder/aac_plugin.c b/src/decoder/aac_plugin.c index fea15fa5b..aed121308 100644 --- a/src/decoder/aac_plugin.c +++ b/src/decoder/aac_plugin.c @@ -33,7 +33,7 @@ typedef struct { size_t bytesIntoBuffer; size_t bytesConsumed; off_t fileOffset; - unsigned char *buffer; + unsigned char buffer[FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS]; } AacBuffer; static void aac_buffer_shift(AacBuffer * b, size_t length) @@ -53,13 +53,13 @@ static void fillAacBuffer(AacBuffer * b) { size_t rest, bread; - if (b->bytesIntoBuffer >= FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS) + if (b->bytesIntoBuffer >= sizeof(b->buffer)) /* buffer already full */ return; aac_buffer_shift(b, b->bytesConsumed); - rest = FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS - b->bytesIntoBuffer; + rest = sizeof(b->buffer) - b->bytesIntoBuffer; bread = decoder_read(b->decoder, b->inStream, (void *)(b->buffer + b->bytesIntoBuffer), rest); @@ -175,9 +175,6 @@ initAacBuffer(AacBuffer * b, struct decoder *decoder, b->decoder = decoder; b->inStream = inStream; - - b->buffer = xmalloc(FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS); - memset(b->buffer, 0, FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS); } static void aac_parse_header(AacBuffer * b, float *length) @@ -336,7 +333,7 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream) #endif faacDecSetConfiguration(decoder, config); - while (b.bytesIntoBuffer < FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS && + while (b.bytesIntoBuffer < sizeof(b.buffer) && !input_stream_eof(b.inStream) && decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) { fillAacBuffer(&b); @@ -423,8 +420,6 @@ aac_stream_decode(struct decoder *mpd_decoder, struct input_stream *inStream) } while (cmd != DECODE_COMMAND_STOP); faacDecClose(decoder); - if (b.buffer) - free(b.buffer); } static struct tag *aacTagDup(const char *file) |