mirror of
https://github.com/mpv-player/mpv
synced 2025-02-16 20:27:23 +00:00
ao_coreaudio_exclusive: fallback to stereo on unknown channel layouts
This is intended for the case when CoreAudio returns only unknown channel layouts, or no channel layout matches the number of channels the CoreAudio device forces. Assume that outputting stereo or mono to the first channels is safe, and that it's better than outputting nothing. It's notable that XBMC/kodi falls back to a static channel layout in this case. For some messed up reason, the layout it uses happens to match with the channel order in ALSA's/mpv's "7.1(alsa)" layout.
This commit is contained in:
parent
0524907c18
commit
0cc440f291
@ -281,6 +281,7 @@ void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
|
||||
struct mp_chmap_sel chmap_sel = {0};
|
||||
ca_retrieve_layouts(ao, &chmap_sel, device);
|
||||
|
||||
// Use any exact match.
|
||||
for (int n = 0; n < chmap_sel.num_chmaps; n++) {
|
||||
if (chmap_sel.chmaps[n].num == channel_count) {
|
||||
MP_VERBOSE(ao, "mismatching channels - fallback #%d\n", n);
|
||||
@ -289,5 +290,13 @@ void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
|
||||
}
|
||||
}
|
||||
|
||||
out_map->num = 0;
|
||||
// Fall back to stereo or mono, and fill the rest with silence. (We don't
|
||||
// know what the device expects. We could use a larger default layout here,
|
||||
// but let's not.)
|
||||
mp_chmap_from_channels(out_map, MPMIN(2, channel_count));
|
||||
out_map->num = channel_count;
|
||||
for (int n = 2; n < out_map->num; n++)
|
||||
out_map->speaker[n] = MP_SPEAKER_ID_NA;
|
||||
MP_WARN(ao, "mismatching channels - falling back to %s\n",
|
||||
mp_chmap_to_str(out_map));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user