Commit 6012a9c9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: add --stereo-mode to replace audio-channels variable (fixes #6)

Since audio-channels was not a configuration item, renaming is a mere
internal matter. This also fixes callback handling and factors code.
parent 3647bd9a
......@@ -115,6 +115,7 @@ typedef int32_t vlc_fixed_t;
#define AOUT_VAR_7_1 8
#define AOUT_VAR_SPDIF 10
#define AOUT_VAR_CHAN_UNSET 0 /* must be zero */
#define AOUT_VAR_CHAN_STEREO 1
#define AOUT_VAR_CHAN_RSTEREO 2
#define AOUT_VAR_CHAN_LEFT 3
......
......@@ -392,7 +392,7 @@ int libvlc_audio_get_channel( libvlc_media_player_t *mp )
if( !p_aout )
return 0;
int val = var_GetInteger( p_aout, "audio-channels" );
int val = var_GetInteger( p_aout, "stereo-mode" );
vlc_object_release( p_aout );
return val;
}
......@@ -408,7 +408,7 @@ int libvlc_audio_set_channel( libvlc_media_player_t *mp, int channel )
if( !p_aout )
return -1;
if( var_SetInteger( p_aout, "audio-channels", channel ) < 0 )
if( var_SetInteger( p_aout, "stereo-mode", channel ) < 0 )
{
libvlc_printerr( "Audio channel out of range" );
ret = -1;
......
......@@ -1710,13 +1710,9 @@ static int AudioConfig( vlc_object_t *p_this, char const *psz_cmd,
return VLC_ENOOBJ;
if ( !strcmp( psz_cmd, "adev" ) )
{
psz_variable = "audio-device";
}
else
{
psz_variable = "audio-channels";
}
psz_variable = "stereo-mode";
/* Get the descriptive name of the variable */
var_Change( p_aout, psz_variable, VLC_VAR_GETTEXT,
......
......@@ -498,7 +498,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
audio_output_t * p_aout = input_GetAout(p_input);
if (p_aout != NULL) {
[self setupVarMenuItem: o_mi_channels target: (vlc_object_t *)p_aout
var: "audio-channels" selector: @selector(toggleVar:)];
var: "stereo-mode" selector: @selector(toggleVar:)];
[self setupVarMenuItem: o_mi_device target: (vlc_object_t *)p_aout
var: "audio-device" selector: @selector(toggleVar:)];
......
......@@ -255,7 +255,7 @@ static int AudioAutoMenuBuilder( audio_output_t *p_object,
QVector<const char *> &varnames )
{
PUSH_INPUTVAR( "audio-es" );
PUSH_VAR( "audio-channels" );
PUSH_VAR( "stereo-mode" );
PUSH_VAR( "audio-device" );
PUSH_VAR( "visual" );
return VLC_SUCCESS;
......@@ -596,7 +596,7 @@ QMenu *VLCMenuBar::AudioMenu( intf_thread_t *p_intf, QMenu * current )
if( current->isEmpty() )
{
addActionWithSubmenu( current, "audio-es", qtr( "Audio &Track" ) );
addActionWithSubmenu( current, "audio-channels", qtr( "Audio &Channels" ) );
addActionWithSubmenu( current, "stereo-mode", qtr( "&Stereo Mode" ) );
addActionWithSubmenu( current, "audio-device", qtr( "Audio &Device" ) );
current->addSeparator();
......
......@@ -569,7 +569,7 @@ commands_ordered = {
{ "volup"; { func = ret_print(vlc.volume.up,"( audio volume: "," )"); args = "[X]"; help = "raise audio volume X steps" } };
{ "voldown"; { func = ret_print(vlc.volume.down,"( audio volume: "," )"); args = "[X]"; help = "lower audio volume X steps" } };
{ "adev"; { func = skip(listvalue("aout","audio-device")); args = "[X]"; help = "set/get audio device" } };
{ "achan"; { func = skip(listvalue("aout","audio-channels")); args = "[X]"; help = "set/get audio channels" } };
{ "achan"; { func = skip(listvalue("aout","stereo-mode")); args = "[X]"; help = "set/get stereo audio output mode" } };
{ "atrack"; { func = skip(listvalue("input","audio-es")); args = "[X]"; help = "set/get audio track" } };
{ "vtrack"; { func = skip(listvalue("input","video-es")); args = "[X]"; help = "set/get video track" } };
{ "vratio"; { func = skip(listvalue("vout","aspect-ratio")); args = "[X]"; help = "set/get video aspect ratio" } };
......
......@@ -91,7 +91,7 @@ int aout_DecNew( audio_output_t *p_aout,
/* Create the audio output stream */
var_Destroy( p_aout, "audio-device" );
var_Destroy( p_aout, "audio-channels" );
var_Destroy( p_aout, "stereo-mode" );
owner->input_format = *p_format;
vlc_atomic_set (&owner->restart, 0);
......@@ -139,7 +139,7 @@ void aout_Shutdown (audio_output_t *p_aout)
aout_volume_Delete (owner->volume);
}
var_Destroy( p_aout, "audio-device" );
var_Destroy( p_aout, "audio-channels" );
var_Destroy( p_aout, "stereo-mode" );
aout_unlock( p_aout );
free (input);
......
......@@ -181,7 +181,7 @@ int aout_ChannelsRestart( vlc_object_t * p_this, const char * psz_variable,
{
/* This is supposed to be a significant change and supposes
* rebuilding the channel choices. */
var_Destroy( p_aout, "audio-channels" );
var_Destroy( p_aout, "stereo-mode" );
}
aout_RequestRestart (p_aout);
return 0;
......
......@@ -98,18 +98,19 @@ int aout_OutputNew( audio_output_t *p_aout,
return -1;
}
if ( var_Type( p_aout, "audio-channels" ) ==
(VLC_VAR_INTEGER | VLC_VAR_HASCHOICE) )
{
if (!var_Type (p_aout, "stereo-mode"))
var_Create (p_aout, "stereo-mode",
VLC_VAR_INTEGER | VLC_VAR_HASCHOICE | VLC_VAR_DOINHERIT);
/* The user may have selected a different channels configuration. */
switch( var_InheritInteger( p_aout, "audio-channels" ) )
var_AddCallback (p_aout, "stereo-mode", aout_ChannelsRestart, NULL);
switch (var_GetInteger (p_aout, "stereo-mode"))
{
case AOUT_VAR_CHAN_RSTEREO:
p_aout->format.i_original_channels |= AOUT_CHAN_REVERSESTEREO;
break;
case AOUT_VAR_CHAN_STEREO:
p_aout->format.i_original_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->format.i_original_channels = AOUT_CHANS_STEREO;
break;
case AOUT_VAR_CHAN_LEFT:
p_aout->format.i_original_channels = AOUT_CHAN_LEFT;
......@@ -119,75 +120,47 @@ int aout_OutputNew( audio_output_t *p_aout,
break;
case AOUT_VAR_CHAN_DOLBYS:
p_aout->format.i_original_channels =
AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_DOLBYSTEREO;
AOUT_CHANS_STEREO | AOUT_CHAN_DOLBYSTEREO;
break;
}
}
else if ( p_aout->format.i_physical_channels == AOUT_CHAN_CENTER
&& (p_aout->format.i_original_channels
& AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) )
{
vlc_value_t val, text;
/* Mono - create the audio-channels variable. */
var_Create( p_aout, "audio-channels",
VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
text.psz_string = _("Audio Channels");
var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL );
val.i_int = AOUT_VAR_CHAN_STEREO; text.psz_string = _("Stereo");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
if ( p_aout->format.i_original_channels & AOUT_CHAN_DUALMONO )
default:
{
/* Go directly to the left channel. */
p_aout->format.i_original_channels = AOUT_CHAN_LEFT;
var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT );
}
var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart,
NULL );
}
else if ( p_aout->format.i_physical_channels ==
(AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)
&& (p_aout->format.i_original_channels &
(AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) )
{
vlc_value_t val, text;
/* Stereo - create the audio-channels variable. */
var_Create( p_aout, "audio-channels",
VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
text.psz_string = _("Audio Channels");
var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL );
if ((p_aout->format.i_original_channels & AOUT_CHAN_PHYSMASK)
!= AOUT_CHANS_STEREO)
break;
if ( p_aout->format.i_original_channels & AOUT_CHAN_DOLBYSTEREO )
vlc_value_t val, txt;
val.i_int = 0;
var_Change (p_aout, "stereo-mode", VLC_VAR_DELCHOICE, &val, NULL);
txt.psz_string = _("Stereo audio mode");
var_Change (p_aout, "stereo-mode", VLC_VAR_SETTEXT, &txt, NULL);
if (p_aout->format.i_original_channels & AOUT_CHAN_DOLBYSTEREO)
{
val.i_int = AOUT_VAR_CHAN_DOLBYS;
text.psz_string = _("Dolby Surround");
txt.psz_string = _("Dolby Surround");
}
else
{
val.i_int = AOUT_VAR_CHAN_STEREO;
text.psz_string = _("Stereo");
txt.psz_string = _("Stereo");
}
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
val.i_int = AOUT_VAR_CHAN_RSTEREO; text.psz_string=_("Reverse stereo");
var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text );
if ( p_aout->format.i_original_channels & AOUT_CHAN_DUALMONO )
{
/* Go directly to the left channel. */
var_Change (p_aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
var_Change (p_aout, "stereo-mode", VLC_VAR_SETVALUE, &val, NULL);
val.i_int = AOUT_VAR_CHAN_LEFT;
txt.psz_string = _("Left");
var_Change (p_aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
if (p_aout->format.i_original_channels & AOUT_CHAN_DUALMONO)
{ /* Go directly to the left channel. */
p_aout->format.i_original_channels = AOUT_CHAN_LEFT;
var_SetInteger( p_aout, "audio-channels", AOUT_VAR_CHAN_LEFT );
var_Change (p_aout, "stereo-mode", VLC_VAR_SETVALUE, &val,
NULL);
}
val.i_int = AOUT_VAR_CHAN_RIGHT;
txt.psz_string = _("Right");
var_Change (p_aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
val.i_int = AOUT_VAR_CHAN_RSTEREO;
txt.psz_string = _("Reverse stereo");
var_Change (p_aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
}
var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart,
NULL );
}
aout_FormatPrepare( &p_aout->format );
......@@ -236,6 +209,7 @@ void aout_OutputDelete (audio_output_t *aout)
if (owner->module == NULL)
return;
var_DelCallback (aout, "stereo-mode", aout_ChannelsRestart, NULL);
module_unneed (aout, owner->module);
aout->volume_set = NULL;
aout->mute_set = NULL;
......
......@@ -43,6 +43,7 @@
//#define Nothing here, this is just to prevent update-po from being stupid
#include "vlc_keys.h"
#include "vlc_meta.h"
#include <vlc_aout.h>
static const char *const ppsz_snap_formats[] =
{ "png", "jpg", "tiff" };
......@@ -202,6 +203,15 @@ static const int pi_force_dolby_values[] = { 0, 1, 2 };
static const char *const ppsz_force_dolby_descriptions[] = {
N_("Auto"), N_("On"), N_("Off") };
#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
};
static const char *const ppsz_stereo_mode_texts[] = { N_("Unset"),
N_("Stereo"), N_("Reverse stereo"),
N_("Left"), N_("Right"), N_("Dolby Surround")
};
#define AUDIO_FILTER_TEXT N_("Audio filters")
#define AUDIO_FILTER_LONGTEXT N_( \
......@@ -1495,6 +1505,8 @@ vlc_module_begin ()
add_integer( "force-dolby-surround", 0, FORCE_DOLBY_TEXT,
FORCE_DOLBY_LONGTEXT, false )
change_integer_list( pi_force_dolby_values, ppsz_force_dolby_descriptions )
add_integer( "stereo-mode", 0, STEREO_MODE_TEXT, STEREO_MODE_TEXT, true )
change_integer_list( pi_stereo_mode_values, ppsz_stereo_mode_texts )
add_integer( "audio-desync", 0, DESYNC_TEXT,
DESYNC_LONGTEXT, true )
change_safe ()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment