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

Martin Storsjö martin at martin.st
Wed Jul 10 13:55:59 CEST 2013


On Tue, 9 Jul 2013, Martin Storsjö 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(-)

If there aren't any objections, I'll probably push this later today. I 
don't know of any problems with it, but just wanted others to be able to 
comment on it before pushing.


> 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;

I realized this probably isn't too good, so I changed it locally to not 
touch i_original_channels any more at this point.

// Martin


More information about the vlc-devel mailing list