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

Thomas Guillem git at videolan.org
Thu Mar 22 09:47:07 CET 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Mar 21 11:10:28 2018 +0100| [872c6011e8e0c978cacf7494e5972ab4b963a6f0] | committer: Thomas Guillem

mmdevice: add a way to enable/disable passthrough

Via the mmdevice-digital-output bool variable. This var is not in the config,
it's inherited from the original mmdevice-passthrough config.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=872c6011e8e0c978cacf7494e5972ab4b963a6f0
---

 modules/audio_output/mmdevice.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index f2aa323eea..f2eebb9a54 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1122,18 +1122,20 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
     const bool b_hdmi = AOUT_FMT_HDMI(fmt);
     if (b_spdif || b_hdmi)
     {
-        switch (var_InheritInteger(aout, "mmdevice-passthrough"))
+        if (!var_GetBool(aout, "mmdevice-digital-output"))
+            return -1;
+
+        if (b_hdmi || fmt->i_format == VLC_CODEC_DTS)
         {
-            case MM_PASSTHROUGH_DISABLED:
-                return -1;
-            case MM_PASSTHROUGH_ENABLED:
+            const bool no_codec_hd =
+                var_InheritInteger(aout, "mmdevice-passthrough") == MM_PASSTHROUGH_ENABLED;
+            if (no_codec_hd)
+            {
                 if (b_hdmi)
                     return -1;
-                else if (fmt->i_format == VLC_CODEC_DTS)
+                else
                     var_SetBool(aout, "dtshd", false );
-                /* falltrough */
-            case MM_PASSTHROUGH_ENABLED_HD:
-                break;
+            }
         }
     }
 
@@ -1237,6 +1239,16 @@ static void Stop(audio_output_t *aout)
     sys->stream = NULL;
 }
 
+static int DigitalOutCallback(vlc_object_t *obj, const char *varname,
+                               vlc_value_t oldval, vlc_value_t newval, void *data)
+{
+    (void) varname; (void) oldval; (void) newval; (void) data;
+    audio_output_t *aout = (audio_output_t *)obj;
+
+    aout_RestartRequest(aout, AOUT_RESTART_OUTPUT);
+    return 0;
+}
+
 static int Open(vlc_object_t *obj)
 {
     audio_output_t *aout = (audio_output_t *)obj;
@@ -1314,6 +1326,14 @@ static int Open(vlc_object_t *obj)
     LeaveCriticalSection(&sys->lock);
     LeaveMTA(); /* Leave MTA after thread has entered MTA */
 
+    int passthrough = var_InheritInteger(aout, "mmdevice-passthrough");
+
+    /* Inherit mmdevice-digital-output bool from mmdevice-passthrough */
+    var_Create(aout, "mmdevice-digital-output", VLC_VAR_BOOL);
+    var_SetBool(aout, "mmdevice-digital-output",
+                passthrough != MM_PASSTHROUGH_DISABLED);
+    var_AddCallback (aout, "mmdevice-digital-output", DigitalOutCallback, NULL);
+
     aout->start = Start;
     aout->stop = Stop;
     aout->time_get = TimeGet;
@@ -1337,6 +1357,8 @@ static void Close(vlc_object_t *obj)
     audio_output_t *aout = (audio_output_t *)obj;
     aout_sys_t *sys = aout->sys;
 
+    var_DelCallback (aout, "mmdevice-digital-output", DigitalOutCallback, NULL);
+
     EnterCriticalSection(&sys->lock);
     sys->requested_device = default_device; /* break out of MMSession() loop */
     sys->it = NULL; /* break out of MMThread() loop */



More information about the vlc-commits mailing list