summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-27 00:45:21 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-27 00:51:48 +0100
commitfb508105d135cfb129c0b1a4d69f6ff03404b67a (patch)
treeb26cdbcfc26522c101be2a0617435c64a6f8b49c
parentaddfcf9ce339f487c94c36f6e72fc7e736586015 (diff)
downloadmpv-fb508105d135cfb129c0b1a4d69f6ff03404b67a.tar.bz2
mpv-fb508105d135cfb129c0b1a4d69f6ff03404b67a.tar.xz
ao_coreaudio: map channel labels needed for 8ch layouts
The code stopped at kAudioChannelLabel_TopBackRight and missed mapping for 5 more channel labels. These are in a completely different order that the mpv ones so they must be mapped manually.
-rw-r--r--audio/out/ao_coreaudio_utils.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c
index 2c12b562cf..2a3cd99028 100644
--- a/audio/out/ao_coreaudio_utils.c
+++ b/audio/out/ao_coreaudio_utils.c
@@ -336,6 +336,33 @@ bool ca_change_format(struct ao *ao, AudioStreamID stream,
return format_set;
}
+static int ca_label_to_mp_speaker_id(AudioChannelLabel label)
+{
+ if (label == kAudioChannelLabel_UseCoordinates ||
+ label == kAudioChannelLabel_Unknown ||
+ label > kAudioChannelLabel_LFE2)
+ return -1;
+
+ if (label <= kAudioChannelLabel_TopBackRight) {
+ return label - 1;
+ } else {
+ // Take care of extra labels after kAudioChannelLabel_TopBackRight
+ switch (label) {
+ case kAudioChannelLabel_RearSurroundLeft:
+ return MP_SPEAKER_ID_SDL;
+ case kAudioChannelLabel_RearSurroundRight:
+ return MP_SPEAKER_ID_SDR;
+ case kAudioChannelLabel_LeftWide:
+ return MP_SPEAKER_ID_WL;
+ case kAudioChannelLabel_RightWide:
+ return MP_SPEAKER_ID_WR;
+ case kAudioChannelLabel_LFE2:
+ return kAudioChannelLabel_LFE2;
+ }
+ return -1;
+ }
+}
+
static bool ca_bitmap_from_ch_desc(struct ao *ao, AudioChannelLayout *layout,
uint32_t *bitmap)
{
@@ -355,14 +382,13 @@ static bool ca_bitmap_from_ch_desc(struct ao *ao, AudioChannelLayout *layout,
for (int j=0; j < ch_num && all_channels_valid; j++) {
AudioChannelLabel label = layout->mChannelDescriptions[j].mChannelLabel;
- if (label == kAudioChannelLabel_UseCoordinates ||
- label == kAudioChannelLabel_Unknown ||
- label > kAudioChannelLabel_TopBackRight) {
+ const int mp_speaker_id = ca_label_to_mp_speaker_id(label);
+ if (mp_speaker_id < 0) {
MP_VERBOSE(ao, "channel label=%d unusable to build channel "
"bitmap, skipping layout\n", label);
all_channels_valid = false;
} else {
- *bitmap |= 1ULL << (label - 1);
+ *bitmap |= 1ULL << mp_speaker_id;
}
}