[vlc-devel] [PATCH 3/9] aout: replace "dtshd" var hack with fmt->extended

Thomas Guillem thomas at gllm.fr
Thu Oct 3 16:33:53 CEST 2019


---
 modules/audio_output/audiotrack.c | 10 +++++-----
 modules/audio_output/mmdevice.c   |  2 +-
 modules/audio_output/wasapi.c     |  4 ++--
 src/input/decoder.c               |  4 +---
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/modules/audio_output/audiotrack.c b/modules/audio_output/audiotrack.c
index a5351c80e5..2cbcbb6f38 100644
--- a/modules/audio_output/audiotrack.c
+++ b/modules/audio_output/audiotrack.c
@@ -1076,7 +1076,7 @@ AudioTrack_Create( JNIEnv *env, audio_output_t *p_aout,
 
 static bool
 AudioTrack_HasEncoding( audio_output_t *p_aout, vlc_fourcc_t i_format,
-                        bool *p_dtshd )
+                        bool extended, bool *p_dtshd )
 {
     aout_sys_t *p_sys = p_aout->sys;
 
@@ -1087,8 +1087,7 @@ AudioTrack_HasEncoding( audio_output_t *p_aout, vlc_fourcc_t i_format,
     switch( i_format )
     {
         case VLC_CODEC_DTS:
-            if( MATCH_ENCODING_FLAG( ENCODING_DTS_HD )
-             && var_GetBool( p_aout, "dtshd" ) )
+            if( MATCH_ENCODING_FLAG( ENCODING_DTS_HD ) && extended )
             {
                 *p_dtshd = true;
                 return true;
@@ -1113,7 +1112,8 @@ StartPassthrough( JNIEnv *env, audio_output_t *p_aout )
     int i_at_format;
 
     bool b_dtshd;
-    if( !AudioTrack_HasEncoding( p_aout, p_sys->fmt.i_format, &b_dtshd ) )
+    if( !AudioTrack_HasEncoding( p_aout, p_sys->fmt.i_format, p_sys->fmt.extended,
+                                 &b_dtshd ) )
         return VLC_EGENERIC;
 
     if( jfields.AudioFormat.has_ENCODING_IEC61937 )
@@ -2196,7 +2196,7 @@ static int DeviceSelect(audio_output_t *p_aout, const char *p_id)
                  i < sizeof( enc_fourccs ) / sizeof( enc_fourccs[0] ); ++i )
             {
                 bool b_dtshd;
-                if( AudioTrack_HasEncoding( p_aout, enc_fourccs[i], &b_dtshd ) )
+                if( AudioTrack_HasEncoding( p_aout, enc_fourccs[i], true, &b_dtshd ) )
                     msg_Dbg( p_aout, "device has %4.4s passthrough support",
                              b_dtshd ? "dtsh" : (const char *)&enc_fourccs[i] );
             }
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index cb05f46597..5d25f93792 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -1121,7 +1121,7 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
                 if (b_hdmi)
                     return -1;
                 else if (fmt->i_format == VLC_CODEC_DTS)
-                    var_SetBool(aout, "dtshd", false );
+                    fmt->extended = false;
                 /* falltrough */
             case MM_PASSTHROUGH_ENABLED_HD:
                 break;
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index c479f8b5bd..4a81dc91d3 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -491,7 +491,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
 
     if (fmt.i_format == VLC_CODEC_DTS)
     {
-        b_dtshd = var_GetBool(vlc_object_parent(s), "dtshd");
+        b_dtshd = pfmt->extended;
         if (b_dtshd)
         {
             b_hdmi = true;
@@ -564,7 +564,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict pfmt,
                      "fallback to 48kHz (S/PDIF) (error 0x%lX)", hr);
             IAudioClient_Release(sys->client);
             free(sys);
-            var_SetBool(vlc_object_parent(s), "dtshd", false);
+            pfmt->extended = false;
             return Start(s, pfmt, sid);
         }
         msg_Err(s, "cannot negotiate audio format (error 0x%lX)%s", hr,
diff --git a/src/input/decoder.c b/src/input/decoder.c
index ffd0467680..28892a9d6f 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -361,10 +361,8 @@ static int ModuleThread_UpdateAudioFormat( decoder_t *p_dec )
         p_aout = input_resource_GetAout( p_owner->p_resource );
         if( p_aout )
         {
-            /* TODO: 3.0 HACK: we need to put i_profile inside audio_format_t
-             * for 4.0 */
             if( p_dec->fmt_out.i_codec == VLC_CODEC_DTS )
-                var_SetBool( p_aout, "dtshd", p_dec->fmt_out.i_profile > 0 );
+                p_dec->fmt_out.audio.extended = p_dec->fmt_out.i_profile > 0;
 
             if( aout_DecNew( p_aout, &format, p_owner->p_clock,
                              &p_dec->fmt_out.audio_replay_gain ) )
-- 
2.20.1



More information about the vlc-devel mailing list