[vlc-devel] [PATCH 8/9] aout: mmdevice: setup DTS_HD output only when needed

Thomas Guillem thomas at gllm.fr
Wed Dec 20 14:12:44 CET 2017


---
 modules/audio_output/mmdevice.c |  3 +++
 modules/audio_output/wasapi.c   | 35 +++++++++++++++--------------------
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index b5fbe16855..b07494cd5b 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1095,6 +1095,9 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
             case MM_PASSTHROUGH_ENABLED:
                 if (b_hdmi)
                     return -1;
+                else if (fmt->i_format == VLC_CODEC_DTS)
+                    var_SetBool(aout, "dtshd", false );
+                /* falltrough */
             case MM_PASSTHROUGH_ENABLED_HD:
                 break;
         }
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index e6bb71ff88..87110b89a3 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -445,8 +445,8 @@ static unsigned vlc_CheckWaveOrder (const WAVEFORMATEX *restrict wf,
 }
 
 
-static HRESULT Restart(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
-                       const GUID *sid, bool force_dts_spdif)
+static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
+                     const GUID *sid)
 {
     static INIT_ONCE freq_once = INIT_ONCE_STATIC_INIT;
 
@@ -467,6 +467,17 @@ static HRESULT Restart(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
     audio_sample_format_t fmt = *pfmt;
     bool b_spdif = AOUT_FMT_SPDIF(&fmt);
     bool b_hdmi = AOUT_FMT_HDMI(&fmt);
+    bool b_dtshd = false;
+
+    if (fmt.i_format == VLC_CODEC_DTS)
+    {
+        b_dtshd = var_GetBool(s->obj.parent, "dtshd");
+        if (b_dtshd)
+        {
+            b_hdmi = true;
+            b_spdif = false;
+        }
+    }
 
     void *pv;
     HRESULT hr = aout_stream_Activate(s, &IID_IAudioClient, NULL, &pv);
@@ -477,17 +488,6 @@ static HRESULT Restart(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
     }
     sys->client = pv;
 
-    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
-         * at 768kHz. We'll also be able to transmit DTS-Core only at this
-         * rate. */
-        b_spdif = false;
-        b_hdmi = true;
-    }
-
     if (b_spdif)
     {
         vlc_SpdifToWave(pwfe, &fmt);
@@ -544,7 +544,8 @@ static HRESULT Restart(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
                      "fallback to 48kHz (S/PDIF)");
             IAudioClient_Release(sys->client);
             free(sys);
-            return Restart(s, pfmt, sid, true);
+            var_SetBool(s->obj.parent, "dtshd", false);
+            return Start(s, pfmt, sid);
         }
         msg_Err(s, "cannot negotiate audio format (error 0x%lx)%s", hr,
                 hr == AUDCLNT_E_UNSUPPORTED_FORMAT
@@ -619,12 +620,6 @@ error:
     return hr;
 }
 
-static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
-                     const GUID *sid)
-{
-    return Restart(s, pfmt, sid, false);
-}
-
 static void Stop(aout_stream_t *s)
 {
     aout_stream_sys_t *sys = s->sys;
-- 
2.11.0



More information about the vlc-devel mailing list