From 4c92247437e24460166558f499e132c1db39d4ef Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sun, 31 Oct 2010 07:37:53 +0200 Subject: [PATCH] ad_libdca: fix assert failure on -channels >6 The decoder had an assert from back when max channels was 6, causing a crash if the user specified -channels 7 or -channels 8. Change the decoder to behave as if -channels 6 had been specified in that case instead. --- libmpcodecs/ad_libdca.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libmpcodecs/ad_libdca.c b/libmpcodecs/ad_libdca.c index a550cbb8d7..fcb4535126 100644 --- a/libmpcodecs/ad_libdca.c +++ b/libmpcodecs/ad_libdca.c @@ -284,7 +284,10 @@ static int preinit(sh_audio_t *sh) struct MPOpts *opts = sh->opts; /* 256 = samples per block, 16 = max number of blocks */ - sh->audio_out_minsize = opts->audio_output_channels * sizeof(int16_t) * 256 * 16; + int channels = opts->audio_output_channels; + if (channels > 6) + channels = 6; + sh->audio_out_minsize = channels * sizeof(int16_t) * 256 * 16; sh->audio_in_minsize = DTSBUFFER_SIZE; sh->samplesize=2; @@ -293,6 +296,7 @@ static int preinit(sh_audio_t *sh) static int init(sh_audio_t *sh) { + struct MPOpts *opts = sh->opts; dts_state_t *s; int flags; int decoded_bytes; @@ -311,8 +315,11 @@ static int init(sh_audio_t *sh) } channels_info(flags); - assert(opts->audio_output_channels >= 1 && opts->audio_output_channels <= 6); - sh->channels = opts->audio_output_channels; + int channels = opts->audio_output_channels; + if (channels > 6) + channels = 6; + assert(channels >= 1 && channels <= 6); + sh->channels = channels; decoded_bytes = decode_audio(sh, sh->a_buffer, 1, sh->a_buffer_size); if(decoded_bytes > 0)