From c890eeac47476acda3ae4e2579b021102139f12c Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 12 Jun 2015 17:45:56 +0200 Subject: audio: use unknown channel layouts if there is no standard layout This is just a conceptual issue, since for now every channel count has an associated standard layout. But should the max. channel count ever be bumped, some things would stop function if mp_chmap_from_channels() refused to work for any channel count within the allowed range. --- audio/chmap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'audio/chmap.c') diff --git a/audio/chmap.c b/audio/chmap.c index 93a15f2f57..2dbed01278 100644 --- a/audio/chmap.c +++ b/audio/chmap.c @@ -97,7 +97,7 @@ static const char *const std_layout_names[][2] = { {0} }; -static const struct mp_chmap default_layouts[MP_NUM_CHANNELS + 1] = { +static const struct mp_chmap default_layouts[] = { {0}, // empty MP_CHMAP_INIT_MONO, // mono MP_CHMAP2(FL, FR), // stereo @@ -217,11 +217,11 @@ void mp_chmap_fill_na(struct mp_chmap *map, int num) // mp_chmap_is_valid(dst) will return false. void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels) { - if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) { - *dst = (struct mp_chmap) {0}; - } else { + *dst = (struct mp_chmap) {0}; + if (num_channels >= 0 && num_channels < MP_ARRAY_SIZE(default_layouts)) *dst = default_layouts[num_channels]; - } + if (!dst->num) + mp_chmap_set_unknown(dst, num_channels); } // Try to do what mplayer/mplayer2/mpv did before channel layouts were -- cgit v1.2.3