From fb508105d135cfb129c0b1a4d69f6ff03404b67a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 27 Nov 2013 00:45:21 +0100 Subject: 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. --- audio/out/ao_coreaudio_utils.c | 34 ++++++++++++++++++++++++++++++---- 1 file 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; } } -- cgit v1.2.3