From 7e285a6f718a84b06994a4c0196a7469058eb241 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 19 Nov 2015 00:08:07 +0100 Subject: ao_wasapi: work around DTS passthrough failure Apparently, some audio drivers do not support the DTS subtype, but passthrough works anyway if the AC3 subtype is set. Just retry with AC3 if the proper format doesn't work. The audio device which exposed this behavior reported itself as "M601d-A3/A3R (Intel(R) Display Audio)". xbmc/kodi even always passes DTS as AC3. --- audio/out/ao_wasapi_utils.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'audio/out/ao_wasapi_utils.c') diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 1f885004a9..108db17d32 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -399,6 +399,23 @@ exit_label: return false; } +// This works like try_format_exclusive(), but will try to fallback to the AC3 +// format if the format is a non-AC3 passthrough format. *wformat will be +// adjusted accordingly. +static bool try_format_exclusive_with_spdif_fallback(struct ao *ao, + WAVEFORMATEXTENSIBLE *wformat) +{ + if (try_format_exclusive(ao, wformat)) + return true; + int special_format = special_subtype_to_format(&wformat->SubFormat); + if (special_format && special_format != AF_FORMAT_S_AC3) { + MP_VERBOSE(ao, "Retrying as AC3.\n"); + wformat->SubFormat = *format_to_subtype(AF_FORMAT_S_AC3); + return try_format_exclusive(ao, wformat); + } + return false; +} + static bool search_sample_formats(struct ao *ao, WAVEFORMATEXTENSIBLE *wformat, int samplerate, struct mp_chmap *channels) { @@ -508,7 +525,7 @@ static bool find_formats_exclusive(struct ao *ao, bool do_search) // Try the requested format as is. If that doesn't work, and the // do_search argument is set, do the pcm format search. - if (!try_format_exclusive(ao, &wformat) && + if (!try_format_exclusive_with_spdif_fallback(ao, &wformat) && (!do_search || !search_channels(ao, &wformat))) return false; -- cgit v1.2.3