[vlc-devel] [PATCH 13/13] aout: mmdevice: handle VLC_CODEC_DTSHD

Thomas Guillem thomas at gllm.fr
Tue Dec 19 12:38:44 CET 2017


Configure the IEC958 rate at 768kHz for DTSHD, if it fails or if disabled by
the user, fallback to DTS core only.
---
 modules/audio_output/mmdevice.c |  7 ++++++-
 modules/audio_output/wasapi.c   | 28 +++++++---------------------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index b5fbe16855..764fbe0a18 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1094,7 +1094,12 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
                 return -1;
             case MM_PASSTHROUGH_ENABLED:
                 if (b_hdmi)
-                    return -1;
+                {
+                    if (fmt->i_format == VLC_CODEC_DTSHD)
+                        fmt->i_format = VLC_CODEC_DTS;
+                    else
+                        return -1;
+                }
             case MM_PASSTHROUGH_ENABLED_HD:
                 break;
         }
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index e6bb71ff88..8f7ace405d 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -262,6 +262,7 @@ static void vlc_HdmiToWave(WAVEFORMATEXTENSIBLE_IEC61937 *restrict wf_iec61937,
     switch (audio->i_format)
     {
     case VLC_CODEC_DTS:
+    case VLC_CODEC_DTSHD:
         wf->SubFormat = _KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD;
         wf->Format.nChannels = 8;
         wf->dwChannelMask = KSAUDIO_SPEAKER_7POINT1;
@@ -306,6 +307,7 @@ static void vlc_SpdifToWave(WAVEFORMATEXTENSIBLE *restrict wf,
     switch (audio->i_format)
     {
     case VLC_CODEC_DTS:
+    case VLC_CODEC_DTSHD:
         wf->SubFormat = _KSDATAFORMAT_SUBTYPE_IEC61937_DTS;
         break;
     case VLC_CODEC_SPDIFL:
@@ -445,8 +447,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;
 
@@ -477,17 +479,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);
@@ -538,13 +529,14 @@ static HRESULT Restart(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
 
     if (FAILED(hr))
     {
-        if (pfmt->i_format == VLC_CODEC_DTS && b_hdmi)
+        if (pfmt->i_format == VLC_CODEC_DTSHD)
         {
             msg_Warn(s, "cannot negotiate DTS at 768khz IEC958 rate (HDMI), "
                      "fallback to 48kHz (S/PDIF)");
             IAudioClient_Release(sys->client);
             free(sys);
-            return Restart(s, pfmt, sid, true);
+            pfmt->i_format = VLC_CODEC_DTS;
+            return Start(s, pfmt, sid);
         }
         msg_Err(s, "cannot negotiate audio format (error 0x%lx)%s", hr,
                 hr == AUDCLNT_E_UNSUPPORTED_FORMAT
@@ -619,12 +611,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