[vlc-devel] [PATCH] mmdevice: add a way to disable passthrough

Thomas Guillem thomas at gllm.fr
Thu Dec 14 16:34:34 CET 2017


cf. http://nucblog.net/2017/03/intel-releases-the-final-hdmi-firmware-for-apollo-and-kaby-lake/

There will always bugs in the OSes, drivers, HDMI firmwares, or HDMI receivers.
The users will always need a way to disable passthrough if it doesn't work.
Contrary to other OSes like Linux or macOS, I didn't find any way to disable a
codec for passthrough.

Refs #18112
Fixes #19279
---

PS: I don't have the HW to test this patch right now, I'll build and test it
tomorrow.

 modules/audio_output/mmdevice.c | 35 +++++++++++++++++++++++++++++++++++
 modules/audio_output/mmdevice.h |  5 +++++
 modules/audio_output/wasapi.c   |  4 ++--
 3 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index e141d721e1..06810dbd7d 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1084,6 +1084,22 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
     if (sys->dev == NULL)
         return -1;
 
+    const bool b_spdif = AOUT_FMT_SPDIF(fmt);
+    const bool b_hdmi = AOUT_FMT_HDMI(fmt);
+    if (b_spdif || b_hdmi)
+    {
+        switch (var_InheritInteger(aout, "audio-passthrough"))
+        {
+            case MM_PASSTHROUGH_DISABLED:
+                return -1;
+            case MM_PASSTHROUGH_ENABLED:
+                if (b_hdmi)
+                    return -1;
+            case MM_PASSTHROUGH_ENABLED_ALL:
+                break;
+        }
+    }
+
     aout_stream_t *s = vlc_object_create(aout, sizeof (*s));
     if (unlikely(s == NULL))
         return -1;
@@ -1264,6 +1280,21 @@ static void Close(vlc_object_t *obj)
     free(sys);
 }
 
+#define MM_PASSTHROUGH_TEXT N_( \
+    "Disable HDMI audio passthrough")
+#define MM_PASSTHROUGH_LONGTEXT N_( \
+    "Change this value if you have issue with HD codecs when using a HDMI receiver.")
+static const int pi_audio_passthrough_values[] = {
+    MM_PASSTHROUGH_DISABLED,
+    MM_PASSTHROUGH_ENABLED,
+    MM_PASSTHROUGH_ENABLED_HD,
+};
+static const char *const ppsz_audio_passthrough_texts[] = {
+    N_("Disabled"),
+    N_("Enabled (without HD codecs support)"),
+    N_("Enabled"),
+};
+
 vlc_module_begin()
     set_shortname("MMDevice")
     set_description(N_("Windows Multimedia Device output"))
@@ -1274,4 +1305,8 @@ vlc_module_begin()
     add_module("mmdevice-backend", "aout stream", "any",
                N_("Output back-end"), N_("Audio output back-end interface."),
                true)
+    add_integer( "audio-passthrough", MM_PASSTHROUGH_DEFAULT,
+                 MM_PASSTHROUGH_TEXT, MM_PASSTHROUGH_LONGTEXT, false )
+        change_integer_list( pi_audio_passthrough_values,
+                             ppsz_audio_passthrough_texts )
 vlc_module_end()
diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h
index f68f8c007b..00050d7504 100644
--- a/modules/audio_output/mmdevice.h
+++ b/modules/audio_output/mmdevice.h
@@ -21,6 +21,11 @@
 #ifndef VLC_AOUT_MMDEVICE_H
 # define VLC_AOUT_MMDEVICE_H 1
 
+#define MM_PASSTHROUGH_DISABLED 0
+#define MM_PASSTHROUGH_ENABLED 1
+#define MM_PASSTHROUGH_ENABLED_HD 2
+#define MM_PASSTHROUGH_DEFAULT MM_PASSTHROUGH_ENABLED_HD
+
 typedef struct aout_stream aout_stream_t;
 
 /**
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index bd4e0ec767..a83ddce2f8 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -477,8 +477,8 @@ static HRESULT Restart(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
     }
     sys->client = pv;
 
-    if (b_spdif && !b_hdmi && fmt.i_format == VLC_CODEC_DTS && !force_dts_spdif
-     && fmt.i_rate >= 48000)
+    if (fmt.i_format == VLC_CODEC_DTS && !force_dts_spdif && fmt.i_rate >= 48000
+     && var_InheritInteger(aout, "audio-passthrough") == MM_PASSTHROUGH_ENABLED_HD)
     {
         /* Try to configure the output rate (IEC958 rate) at 768kHz. Indeed,
          * DTS-HD (and other DTS extensions like DTS-X) can only be transmitted
-- 
2.11.0



More information about the vlc-devel mailing list