From 4b65bd5086f832228303cd891a6abd231eeea790 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 16 Dec 2014 13:03:43 +0100 Subject: ao_coreaudio: fix mono/stereo channel mapping Needed after af3bbb800d since now we use channel mapping all the time. Fixes #1357 --- audio/out/ao_coreaudio.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c index 47ad69b415..7ccc2c212a 100644 --- a/audio/out/ao_coreaudio.c +++ b/audio/out/ao_coreaudio.c @@ -194,12 +194,6 @@ static bool init_chmap(struct ao *ao) talloc_free(layouts); - if (ao->channels.num < 3) { - struct mp_chmap chmap; - mp_chmap_from_channels(&chmap, ao->channels.num); - mp_chmap_sel_add_map(&chmap_sel, &chmap); - } - if (!ao_chmap_sel_adjust(ao, &chmap_sel, &ao->channels)) { MP_ERR(ao, "could not select a suitable channel map among the " "hardware supported ones. Make sure to configure your " @@ -336,7 +330,7 @@ static const int speaker_map[][2] = { { kAudioChannelLabel_HeadphonesLeft, MP_SPEAKER_ID_DL }, { kAudioChannelLabel_HeadphonesRight, MP_SPEAKER_ID_DR }, - { kAudioChannelLabel_Unknown, -1 }, + { kAudioChannelLabel_Unknown, MP_SPEAKER_ID_UNKNOWN0 }, }; static int ca_label_to_mp_speaker_id(AudioChannelLabel label) @@ -426,8 +420,6 @@ bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout, for (int n = 0; n < layout->mNumberChannelDescriptions; n++) { AudioChannelLabel label = layout->mChannelDescriptions[n].mChannelLabel; uint8_t speaker = ca_label_to_mp_speaker_id(label); - if (label == kAudioChannelLabel_Unknown) - continue; if (speaker < 0) { MP_VERBOSE(ao, "channel label=%u unusable to build channel " "bitmap, skipping layout\n", (unsigned) label); @@ -438,6 +430,12 @@ bool ca_layout_to_mp_chmap(struct ao *ao, AudioChannelLayout *layout, } } + // In OS X systems with unconfigured multichannel, coreaudio reports + // speakers with an unknown channel label. Just assume those are stereo + // and mono + if (mp_chmap_is_unknown(chmap) && chmap->num < 3) + mp_chmap_from_channels(chmap, chmap->num); + return chmap->num > 0; coreaudio_error: ca_log_layout(ao, layout); -- cgit v1.2.3