From c971fefd41f530e7974dd262c22e3b0915f1756a Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 26 Oct 2015 15:54:45 +0100 Subject: ao_coreaudio_chmap: allow stereo as fallback; avoid mono fallback If no channel layouts were determined (which can actually happen with some "strange" devices), the selection code was falling back to mono, because mono is always added as a fallback. This doesn't seem quite right. Allow a fallback to stereo too, if no channel layout could be retrieved at all. So we always assume that mono and stereo work, if no other layouts are available. (I still don't know what the CoreAudio stereo layout is supposed to do. It could be used to swap left and right channels. It could also be used to pad/move the channels, but I have never seen that. And it can be set to non-stereo channels, which breaks mpv. Whatever.) --- audio/out/ao_coreaudio_chmap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'audio/out') diff --git a/audio/out/ao_coreaudio_chmap.c b/audio/out/ao_coreaudio_chmap.c index 94c9179db8..1f299cedc2 100644 --- a/audio/out/ao_coreaudio_chmap.c +++ b/audio/out/ao_coreaudio_chmap.c @@ -242,8 +242,6 @@ bool ca_init_chmap(struct ao *ao, AudioDeviceID device) struct mp_chmap_sel chmap_sel = {.tmp = ta_ctx}; struct mp_chmap chmap = {0}; - mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_MONO); - AudioChannelLayout *ml = ca_query_layout(ao, device, ta_ctx); if (ml && ca_layout_to_mp_chmap(ao, ml, &chmap)) mp_chmap_sel_add_map(&chmap_sel, &chmap); @@ -252,6 +250,11 @@ bool ca_init_chmap(struct ao *ao, AudioDeviceID device) if (sl && ca_layout_to_mp_chmap(ao, sl, &chmap)) mp_chmap_sel_add_map(&chmap_sel, &chmap); + if (!chmap_sel.num_chmaps) + mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_STEREO); + + mp_chmap_sel_add_map(&chmap_sel, &(struct mp_chmap)MP_CHMAP_INIT_MONO); + 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 " -- cgit v1.2.3