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

Rémi Denis-Courmont remi at remlab.net
Wed Jul 10 14:09:43 CEST 2013


On Tue,  9 Jul 2013 16:42:04 +0300, Martin Storsjö <martin at martin.st>
wrote:
> 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;

This won't work if the audio output insists on stereo (e.g. ALSA). It will
only work if the audio output accepts mono and the back-end transparently
upmixes back to stereo (e.g. PulseAudio). 

> +
> +    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"))

-- 
Rémi Denis-Courmont
Sent from my collocated server



More information about the vlc-devel mailing list