[vlc-devel] [PATCH] aout: Add a 'mono' option to the stereo-mode parameter

Martin Storsjö martin at martin.st
Tue Jul 9 15:42:04 CEST 2013


This parameter value needs to be dealt with before starting the
actual aout, which is why the aout->Start call is moved down
to after the stereo-mode parameter is created.

---
Tested to work properly with the android_audiotrack output
(with a patch that adds a gui preference for enabling this mode).

Also tested on linux with the qt4 gui, where the new option appeared
properly in the gui and seemed to work as intended.

(However, the stereo mode submenu appeared grayed out when playing an
8-channel audio file, while it appeared normally and worked fine when
playing a video with 2 audio channels.)
---
 include/vlc_aout.h        |    1 +
 src/audio_output/output.c |   19 +++++++++++++------
 src/libvlc-module.c       |    6 ++++--
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 49c0ec6..62a1e83 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -83,6 +83,7 @@
 #define AOUT_VAR_CHAN_LEFT          3
 #define AOUT_VAR_CHAN_RIGHT         4
 #define AOUT_VAR_CHAN_DOLBYS        5
+#define AOUT_VAR_CHAN_MONO          6
 
 /*****************************************************************************
  * Main audio output structures
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 988d200..d0e5afa 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -362,12 +362,6 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
         aout_FormatPrepare (fmt);
     }
 
-    if (aout->start (aout, fmt))
-    {
-        msg_Err (aout, "module not functional");
-        return -1;
-    }
-
     if (!var_Type (aout, "stereo-mode"))
     {
         var_Create (aout, "stereo-mode",
@@ -378,6 +372,15 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
         var_Change (aout, "stereo-mode", VLC_VAR_SETTEXT, &txt, NULL);
     }
 
+    if (var_GetInteger (aout, "stereo-mode") == AOUT_VAR_CHAN_MONO)
+        fmt->i_original_channels = fmt->i_physical_channels = AOUT_CHAN_CENTER;
+
+    if (aout->start (aout, fmt))
+    {
+        msg_Err (aout, "module not functional");
+        return -1;
+    }
+
     /* The user may have selected a different channels configuration. */
     var_AddCallback (aout, "stereo-mode", aout_ChannelsRestart, NULL);
     switch (var_GetInteger (aout, "stereo-mode"))
@@ -386,6 +389,7 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
             fmt->i_original_channels |= AOUT_CHAN_REVERSESTEREO;
             break;
         case AOUT_VAR_CHAN_STEREO:
+        case AOUT_VAR_CHAN_MONO:
             fmt->i_original_channels = AOUT_CHANS_STEREO;
             break;
         case AOUT_VAR_CHAN_LEFT:
@@ -432,6 +436,9 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
             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_MONO;
+            txt.psz_string = _("Mono");
+            var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
         }
     }
 
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 94faf8e..b9e3380 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -182,11 +182,13 @@ static const char *const ppsz_force_dolby_descriptions[] = {
 #define STEREO_MODE_TEXT N_("Stereo audio output mode")
 static const int pi_stereo_mode_values[] = { AOUT_VAR_CHAN_UNSET,
     AOUT_VAR_CHAN_STEREO, AOUT_VAR_CHAN_RSTEREO,
-    AOUT_VAR_CHAN_LEFT, AOUT_VAR_CHAN_RIGHT, AOUT_VAR_CHAN_DOLBYS
+    AOUT_VAR_CHAN_LEFT, AOUT_VAR_CHAN_RIGHT, AOUT_VAR_CHAN_DOLBYS,
+    AOUT_VAR_CHAN_MONO
 };
 static const char *const ppsz_stereo_mode_texts[] = { N_("Unset"),
     N_("Stereo"), N_("Reverse stereo"),
-    N_("Left"), N_("Right"), N_("Dolby Surround")
+    N_("Left"), N_("Right"), N_("Dolby Surround"),
+    N_("Mono")
 };
 
 #define AUDIO_FILTER_TEXT N_("Audio filters")
-- 
1.7.9.4




More information about the vlc-devel mailing list