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

Thomas Guillem git at videolan.org
Fri Dec 15 17:44:20 CET 2017


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Dec 14 16:42:04 2017 +0100| [45dbfe4e78015d9e84c68fc793ccc0fcf6eef23b] | committer: Thomas Guillem

mmdevice: add a way to disable passthrough

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

There will be always bugs in  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
passthrough for a codec.

Refs #18112
Fixes #19279

(cherry picked from commit d913ae19b425c3d001f1fefd241802f9f5e47aee)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=45dbfe4e78015d9e84c68fc793ccc0fcf6eef23b
---

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

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index b6d116622e..be1c3587de 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1089,6 +1089,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, "mmdevice-passthrough"))
+        {
+            case MM_PASSTHROUGH_DISABLED:
+                return -1;
+            case MM_PASSTHROUGH_ENABLED:
+                if (b_hdmi)
+                    return -1;
+            case MM_PASSTHROUGH_ENABLED_HD:
+                break;
+        }
+    }
+
     aout_stream_t *s = vlc_object_create(aout, sizeof (*s));
     if (unlikely(s == NULL))
         return -1;
@@ -1266,9 +1282,25 @@ static void Close(vlc_object_t *obj)
 
     vlc_join(sys->thread, NULL);
     DeleteCriticalSection(&sys->lock);
+
     free(sys);
 }
 
+#define MM_PASSTHROUGH_TEXT N_( \
+    "HDMI/SPDIF 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_mmdevice_passthrough_values[] = {
+    MM_PASSTHROUGH_DISABLED,
+    MM_PASSTHROUGH_ENABLED,
+    MM_PASSTHROUGH_ENABLED_HD,
+};
+static const char *const ppsz_mmdevice_passthrough_texts[] = {
+    N_("Disabled"),
+    N_("Enabled (without HD codecs)"),
+    N_("Enabled"),
+};
+
 vlc_module_begin()
     set_shortname("MMDevice")
     set_description(N_("Windows Multimedia Device output"))
@@ -1279,4 +1311,8 @@ vlc_module_begin()
     add_module("mmdevice-backend", "aout stream", "any",
                N_("Output back-end"), N_("Audio output back-end interface."),
                true)
+    add_integer( "mmdevice-passthrough", MM_PASSTHROUGH_DEFAULT,
+                 MM_PASSTHROUGH_TEXT, MM_PASSTHROUGH_LONGTEXT, false )
+        change_integer_list( pi_mmdevice_passthrough_values,
+                             ppsz_mmdevice_passthrough_texts )
 vlc_module_end()
diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h
index 3c7b6d35ba..41dae596e5 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 abe7825b0e..5f56fd6979 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -482,8 +482,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(s, "mmdevice-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



More information about the vlc-commits mailing list