X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aacdec_filter.c;h=2dd68448b3b130172ba3417cb20eedcfc1fff262;hp=5166555272c672ecda4bd4109d2e29b06b90aa4d;hb=009e80ae25df7a247a263b5b8e2259c9bdfe20ce;hpb=7e39ff04bb18e5c050e92d5047335c4f09ac9b28 diff --git a/aacdec_filter.c b/aacdec_filter.c index 51665552..2dd68448 100644 --- a/aacdec_filter.c +++ b/aacdec_filter.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2009 Andre Noll + * Copyright (C) 2006-2010 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -23,10 +23,7 @@ #include "string.h" #include "aac.h" -/** the output buffer size */ -#define AAC_OUTBUF_SIZE (32 * 1024) - -/** give up decoding after that many errors */ +/** Give up decoding after that many errors. */ #define MAX_ERRORS 20 /** @@ -55,7 +52,7 @@ struct private_aacdec_data { /** The number of channels of the current stream. */ unsigned int channels; /** Current sample rate in Hz. */ - unsigned int samplerate; + unsigned int sample_rate; }; static int aacdec_execute(struct btr_node *btrn, const char *cmd, char **result) @@ -63,19 +60,7 @@ static int aacdec_execute(struct btr_node *btrn, const char *cmd, char **result) struct filter_node *fn = btr_context(btrn); struct private_aacdec_data *padd = fn->private_data; - if (!strcmp(cmd, "samplerate")) { - if (padd->samplerate == 0) - return -ERRNO_TO_PARA_ERROR(ENAVAIL); - *result = make_message("%u", padd->samplerate); - return 1; - } - if (!strcmp(cmd, "channels")) { - if (padd->channels == 0) - return -ERRNO_TO_PARA_ERROR(ENAVAIL); - *result = make_message("%u", padd->channels); - return 1; - } - return -ERRNO_TO_PARA_ERROR(ENOTSUP); + return decoder_execute(cmd, padd->sample_rate, padd->channels, result); } static void aacdec_open(struct filter_node *fn) @@ -83,8 +68,6 @@ static void aacdec_open(struct filter_node *fn) struct private_aacdec_data *padd = para_calloc(sizeof(*padd)); fn->private_data = padd; - fn->bufsize = AAC_OUTBUF_SIZE; - fn->buf = para_calloc(fn->bufsize); fn->min_iqs = 2048; padd->handle = aac_open(); } @@ -94,8 +77,6 @@ static void aacdec_close(struct filter_node *fn) struct private_aacdec_data *padd = fn->private_data; NeAACDecClose(padd->handle); - free(fn->buf); - fn->buf = NULL; free(padd); fn->private_data = NULL; } @@ -119,6 +100,7 @@ next_buffer: return; btr_merge(btrn, fn->min_iqs); len = btr_next_buffer(btrn, (char **)&inbuf); + len = PARA_MAX(len, (size_t)8192); consumed = 0; iqs = btr_get_input_queue_size(btrn); if (!padd->initialized) { @@ -146,10 +128,10 @@ next_buffer: &channels) < 0) goto out; } - padd->samplerate = rate; + padd->sample_rate = rate; padd->channels = channels; PARA_INFO_LOG("rate: %u, channels: %d\n", - padd->samplerate, padd->channels); + padd->sample_rate, padd->channels); padd->initialized = 1; } if (padd->decoder_length > 0) {