[vlc-devel] [PATCH 3/6] aout: prepare the stereo-mode before starting the aout

Thomas Guillem thomas at gllm.fr
Thu Jul 16 14:25:32 CEST 2020


This will allow to change aout->mixer_format before starting the aout and
remove some special stereo-mode handling outside of stereo-mode functions, cf.
next commit.

The aout->current_sink_info.headphones special case is still handled after the
vout is started. At this point, only the filters need to be updated (via
filters_cfg).
---
 src/audio_output/output.c | 43 +++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 24af7225fb6..750139f4ad3 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -534,6 +534,8 @@ int aout_OutputNew (audio_output_t *aout)
         fmt->i_format, 0, 0
     };
 
+    var_Change(aout, "stereo-mode", VLC_VAR_CLEARCHOICES);
+
     /* Ideally, the audio filters would be created before the audio output,
      * and the ideal audio format would be the output of the filters chain.
      * But that scheme would not really play well with digital pass-through. */
@@ -564,6 +566,20 @@ int aout_OutputNew (audio_output_t *aout)
           || owner->requested_stereo_mode == AOUT_VAR_CHAN_RIGHT))
             fmt->i_physical_channels = AOUT_CHAN_CENTER;
 
+        if (i_nb_input_channels != 1)
+        {
+            int default_stereo_mode =
+                aout_PrepareStereoMode(aout, fmt, input_chan_type,
+                                       i_nb_input_channels);
+
+            /* Prefer the user requested mode if available, otherwise, use the
+             * default one */
+            int stereo_mode = aout_HasStereoMode(aout, owner->requested_stereo_mode) ?
+                              owner->requested_stereo_mode : default_stereo_mode;
+
+            aout_UpdateStereoMode(aout, stereo_mode, fmt, filters_cfg);
+        }
+
         aout_FormatPrepare (fmt);
         assert (aout_FormatNbChannels(fmt) > 0);
     }
@@ -610,27 +626,14 @@ int aout_OutputNew (audio_output_t *aout)
     }
     assert(aout->flush && aout->play && aout->time_get && aout->pause);
 
-    var_Change(aout, "stereo-mode", VLC_VAR_CLEARCHOICES);
-
-    if (AOUT_FMT_LINEAR(fmt) && i_nb_input_channels != 1)
+    /* Autoselect the headphones mode if available and if the user didn't
+     * request any mode */
+    if (aout->current_sink_info.headphones
+     && owner->requested_stereo_mode == AOUT_VAR_CHAN_UNSET
+     && aout_HasStereoMode(aout, AOUT_VAR_CHAN_HEADPHONES))
     {
-        int default_stereo_mode =
-            aout_PrepareStereoMode(aout, fmt, input_chan_type,
-                                   i_nb_input_channels);
-
-        /* Prefer the user requested mode if available, otherwise, use the
-         * default one */
-        int stereo_mode = aout_HasStereoMode(aout, owner->requested_stereo_mode) ?
-                          owner->requested_stereo_mode : default_stereo_mode;
-
-        /* Autoselect the headphones mode if available and if the user didn't
-         * request any mode */
-        if (aout->current_sink_info.headphones
-         && owner->requested_stereo_mode == AOUT_VAR_CHAN_UNSET
-         && aout_HasStereoMode(aout, AOUT_VAR_CHAN_HEADPHONES))
-            stereo_mode = AOUT_VAR_CHAN_HEADPHONES;
-
-        aout_UpdateStereoMode(aout, stereo_mode, fmt, filters_cfg);
+        assert(fmt->i_physical_channels == AOUT_CHANS_STEREO);
+        aout_UpdateStereoMode(aout, AOUT_VAR_CHAN_HEADPHONES, fmt, filters_cfg);
     }
 
     aout_FormatPrepare (fmt);
-- 
2.20.1



More information about the vlc-devel mailing list