summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-10-31 07:37:53 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:18:07 +0200
commit4c92247437e24460166558f499e132c1db39d4ef (patch)
tree77be43b6efaef0ea1c3d29c30c3c6d6d62440712
parent4de0369e8d6d8d497b3aa61044a152ae91d477a6 (diff)
downloadmpv-4c92247437e24460166558f499e132c1db39d4ef.tar.bz2
mpv-4c92247437e24460166558f499e132c1db39d4ef.tar.xz
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.
-rw-r--r--libmpcodecs/ad_libdca.c13
1 files 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)