diff options
author | wm4 <wm4@nowhere> | 2015-10-21 18:54:48 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-10-21 18:54:48 +0200 |
commit | dda16ee1fbe681ad747210aaea7727a3378c9af2 (patch) | |
tree | 4173267c71a2bee59ad4386655c35ec616025703 /audio/out/ao_coreaudio_chmap.c | |
parent | 78112c858246f9018140d87d8cfc32868ff56fbb (diff) | |
download | mpv-dda16ee1fbe681ad747210aaea7727a3378c9af2.tar.bz2 mpv-dda16ee1fbe681ad747210aaea7727a3378c9af2.tar.xz |
ao_coreaudio_exclusive: deal with devices return different channel count
If the device returns an unexpected number of channels instead of the
requested count on init, don't immediately error out. Instead, look if
there's a channel map with the given number of channels.
If there isn't, still error out, because we don't want to guess the
channel layout.
Diffstat (limited to 'audio/out/ao_coreaudio_chmap.c')
-rw-r--r-- | audio/out/ao_coreaudio_chmap.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/audio/out/ao_coreaudio_chmap.c b/audio/out/ao_coreaudio_chmap.c index b1572dabd1..0405338828 100644 --- a/audio/out/ao_coreaudio_chmap.c +++ b/audio/out/ao_coreaudio_chmap.c @@ -265,3 +265,28 @@ coreaudio_error: talloc_free(ta_ctx); return false; } + +void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count, + struct mp_chmap *out_map) +{ + void *ta_ctx = talloc_new(NULL); + + // Apparently, we have to guess by looking back at the supported layouts, + // and I haven't found a property that retrieves the actual currently + // active channel layout. + + AudioChannelLayout *ml = ca_query_layout(ao, device, ta_ctx); + if (ml && ca_layout_to_mp_chmap(ao, ml, out_map)) { + if (channel_count == out_map->num) + goto done; + } + + AudioChannelLayout *sl = ca_query_stereo_layout(ao, device, ta_ctx); + if (sl && ca_layout_to_mp_chmap(ao, sl, out_map)) { + if (channel_count == out_map->num) + goto done; + } + + out_map->num = 0; +done: ; +} |