[vlc-commits] aout: stereo-mode can now be always forced

Thomas Guillem git at videolan.org
Thu Jul 13 17:19:05 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jul 11 14:03:15 2017 +0200| [caca12fbab4f49d5522b264a72bf8d9d8f13bc4b] | committer: Thomas Guillem

aout: stereo-mode can now be always forced

Can be used to force downmix to stereo.

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

 src/audio_output/output.c | 45 +++++++++++++++++++++++++++++----------------
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 1092e58e0b..ab688df811 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -389,6 +389,11 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
 {
     aout_OutputAssertLocked (aout);
 
+    int i_forced_stereo_mode = var_GetInteger (aout, "stereo-mode");
+    bool b_stereo_original = fmt->i_physical_channels == AOUT_CHANS_STEREO;
+    if (i_forced_stereo_mode != AOUT_VAR_CHAN_UNSET)
+        fmt->i_physical_channels = AOUT_CHANS_STEREO;
+
     /* 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. */
@@ -409,32 +414,40 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
     var_Change (aout, "stereo-mode", VLC_VAR_CLEARCHOICES, NULL, NULL);
     vlc_value_t val, txt, default_val;
     val.i_int = 0;
-    if (fmt->i_physical_channels == AOUT_CHANS_STEREO)
+    if (!b_stereo_original)
     {
-        if (fmt->i_original_channels & AOUT_CHAN_DOLBYSTEREO)
-        {
-            default_val.i_int = val.i_int = AOUT_VAR_CHAN_DOLBYS;
-            txt.psz_string = _("Dolby Surround");
-        }
-        else
-        {
-            default_val.i_int = val.i_int = AOUT_VAR_CHAN_STEREO;
-            txt.psz_string = _("Stereo");
-        }
+        val.i_int = AOUT_VAR_CHAN_UNSET;
+        txt.psz_string = _("Original");
         var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
+    }
+    if (fmt->i_original_channels & AOUT_CHAN_DOLBYSTEREO)
+    {
+        val.i_int = AOUT_VAR_CHAN_DOLBYS;
+        txt.psz_string = _("Dolby Surround");
+    }
+    else
+    {
+        val.i_int = AOUT_VAR_CHAN_STEREO;
+        txt.psz_string = _("Stereo");
+    }
+    var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
+    default_val.i_int = b_stereo_original ? val.i_int : AOUT_VAR_CHAN_UNSET;
+
+    if (b_stereo_original)
+    {
         val.i_int = AOUT_VAR_CHAN_LEFT;
         txt.psz_string = _("Left");
         var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
         val.i_int = AOUT_VAR_CHAN_RIGHT;
         txt.psz_string = _("Right");
         var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
-        val.i_int = AOUT_VAR_CHAN_RSTEREO;
-        txt.psz_string = _("Reverse stereo");
-        var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
     }
+    val.i_int = AOUT_VAR_CHAN_RSTEREO;
+    txt.psz_string = _("Reverse stereo");
+    var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
 
     /* The user may have selected a different channels configuration. */
-    switch (var_GetInteger (aout, "stereo-mode"))
+    switch (i_forced_stereo_mode)
     {
         case AOUT_VAR_CHAN_RSTEREO:
             fmt->i_original_channels |= AOUT_CHAN_REVERSESTEREO;
@@ -452,7 +465,7 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
             fmt->i_original_channels = AOUT_CHANS_STEREO|AOUT_CHAN_DOLBYSTEREO;
             break;
         default:
-            if (fmt->i_original_channels & AOUT_CHAN_DUALMONO)
+            if (fmt->i_original_channels == (AOUT_CHANS_STEREO | AOUT_CHAN_DUALMONO))
             {   /* Go directly to the left channel. */
                 fmt->i_original_channels = AOUT_CHAN_LEFT;
                 val.i_int = AOUT_VAR_CHAN_LEFT;



More information about the vlc-commits mailing list