summaryrefslogtreecommitdiffstats
path: root/audio/chmap.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-06-12 17:45:56 +0200
committerwm4 <wm4@nowhere>2015-06-12 17:45:56 +0200
commitc890eeac47476acda3ae4e2579b021102139f12c (patch)
tree8c6d9209c667beb7ca7c96bc38ba42b33df67be0 /audio/chmap.c
parent11fee81a7af8cd6d6e4038107fdc4bfb142de0cc (diff)
downloadmpv-c890eeac47476acda3ae4e2579b021102139f12c.tar.bz2
mpv-c890eeac47476acda3ae4e2579b021102139f12c.tar.xz
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.
Diffstat (limited to 'audio/chmap.c')
-rw-r--r--audio/chmap.c10
1 files changed, 5 insertions, 5 deletions
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