1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-01 00:07:33 +00:00

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.
This commit is contained in:
Uoti Urpala 2010-10-31 07:37:53 +02:00
parent 4de0369e8d
commit 4c92247437

View File

@ -284,7 +284,10 @@ static int preinit(sh_audio_t *sh)
struct MPOpts *opts = sh->opts; struct MPOpts *opts = sh->opts;
/* 256 = samples per block, 16 = max number of blocks */ /* 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->audio_in_minsize = DTSBUFFER_SIZE;
sh->samplesize=2; sh->samplesize=2;
@ -293,6 +296,7 @@ static int preinit(sh_audio_t *sh)
static int init(sh_audio_t *sh) static int init(sh_audio_t *sh)
{ {
struct MPOpts *opts = sh->opts;
dts_state_t *s; dts_state_t *s;
int flags; int flags;
int decoded_bytes; int decoded_bytes;
@ -311,8 +315,11 @@ static int init(sh_audio_t *sh)
} }
channels_info(flags); channels_info(flags);
assert(opts->audio_output_channels >= 1 && opts->audio_output_channels <= 6); int channels = opts->audio_output_channels;
sh->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); decoded_bytes = decode_audio(sh, sh->a_buffer, 1, sh->a_buffer_size);
if(decoded_bytes > 0) if(decoded_bytes > 0)