summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi_utils.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-11-19 00:08:07 +0100
committerwm4 <wm4@nowhere>2015-11-19 00:08:07 +0100
commit7e285a6f718a84b06994a4c0196a7469058eb241 (patch)
treedca93c73e9b27ab32172ea6735808032c17a3c8e /audio/out/ao_wasapi_utils.c
parent516e7d19da137e7b5b8d19c6f0e093823ecdb3a4 (diff)
downloadmpv-7e285a6f718a84b06994a4c0196a7469058eb241.tar.bz2
mpv-7e285a6f718a84b06994a4c0196a7469058eb241.tar.xz
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.
Diffstat (limited to 'audio/out/ao_wasapi_utils.c')
-rwxr-xr-xaudio/out/ao_wasapi_utils.c19
1 files changed, 18 insertions, 1 deletions
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;