summaryrefslogtreecommitdiffstats
path: root/audio/chmap.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-07 23:15:52 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-09 21:13:52 +0900
commit0ed627d5ab0a41bb33eb54e92a2b3e8890fbdadf (patch)
treecf7ce0a3d77e800be8475192d51e4817404649a3 /audio/chmap.c
parent1127bb41c2aa4bf60be960ab80fd163bc7011bdb (diff)
downloadmpv-0ed627d5ab0a41bb33eb54e92a2b3e8890fbdadf.tar.bz2
mpv-0ed627d5ab0a41bb33eb54e92a2b3e8890fbdadf.tar.xz
audio: remove UNKNOWN pseudo speakers
Reuse MP_SPEAKER_ID_NA for this. If all mp_chmap entries are set to NA, the channel layout has special "unknown channel layout" semantics, which are used to deal with some corner cases. (cherry picked from commit 55e777f10b3e241f2634b471e482bab230773ce0)
Diffstat (limited to 'audio/chmap.c')
-rw-r--r--audio/chmap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/audio/chmap.c b/audio/chmap.c
index 09aa364d59..b48a42325f 100644
--- a/audio/chmap.c
+++ b/audio/chmap.c
@@ -144,12 +144,10 @@ bool mp_chmap_is_empty(const struct mp_chmap *src)
bool mp_chmap_is_unknown(const struct mp_chmap *src)
{
for (int n = 0; n < src->num; n++) {
- int speaker = src->speaker[n];
- if (speaker >= MP_SPEAKER_ID_UNKNOWN0 &&
- speaker <= MP_SPEAKER_ID_UNKNOWN_LAST)
- return true;
+ if (src->speaker[n] != MP_SPEAKER_ID_NA)
+ return false;
}
- return false;
+ return mp_chmap_is_valid(src);
}
// Note: empty channel maps compare as equal. Invalid ones can equal too.
@@ -240,6 +238,8 @@ void mp_chmap_from_channels_alsa(struct mp_chmap *dst, int num_channels)
// Set *dst to an unknown layout for the given numbers of channels.
// If the number of channels is invalid, an invalid map is set, and
// mp_chmap_is_valid(dst) will return false.
+// A mp_chmap with all entries set to NA is treated specially in some
+// contexts (watch out for mp_chmap_is_unknown()).
void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels)
{
if (num_channels < 0 || num_channels > MP_NUM_CHANNELS) {
@@ -247,7 +247,7 @@ void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels)
} else {
dst->num = num_channels;
for (int n = 0; n < dst->num; n++)
- dst->speaker[n] = MP_SPEAKER_ID_UNKNOWN0 + n;
+ dst->speaker[n] = MP_SPEAKER_ID_NA;
}
}