Commit 9c6117e8 authored by Thomas Guillem's avatar Thomas Guillem

aout: increase stereo-mode lifecycle

It's not reset anymore when the aout is restarted
parent db6f938e
......@@ -69,11 +69,6 @@ int aout_DecNew( audio_output_t *p_aout,
return -1;
}
var_Create (p_aout, "stereo-mode", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
vlc_value_t txt;
txt.psz_string = _("Stereo audio mode");
var_Change (p_aout, "stereo-mode", VLC_VAR_SETTEXT, &txt, NULL);
aout_owner_t *owner = aout_owner(p_aout);
/* TODO: reduce lock scope depending on decoder's real need */
......@@ -108,7 +103,6 @@ error:
aout_volume_Delete (owner->volume);
owner->volume = NULL;
aout_OutputUnlock (p_aout);
var_Destroy (p_aout, "stereo-mode");
return -1;
}
......@@ -138,7 +132,6 @@ void aout_DecDelete (audio_output_t *aout)
aout_volume_Delete (owner->volume);
owner->volume = NULL;
aout_OutputUnlock (aout);
var_Destroy (aout, "stereo-mode");
}
static int aout_CheckReady (audio_output_t *aout)
......
......@@ -320,6 +320,13 @@ audio_output_t *aout_New (vlc_object_t *parent)
&val, &text);
}
/* Stereo mode */
var_Create (aout, "stereo-mode", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
var_AddCallback (aout, "stereo-mode", StereoModeCallback, NULL);
vlc_value_t txt;
txt.psz_string = _("Stereo audio mode");
var_Change (aout, "stereo-mode", VLC_VAR_SETTEXT, &txt, NULL);
/* Equalizer */
var_Create (aout, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
var_Create (aout, "equalizer-bands", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
......@@ -348,6 +355,7 @@ void aout_Destroy (audio_output_t *aout)
var_DelCallback (aout, "mute", var_Copy, aout->obj.parent);
var_SetFloat (aout, "volume", -1.f);
var_DelCallback (aout, "volume", var_Copy, aout->obj.parent);
var_DelCallback (aout, "stereo-mode", StereoModeCallback, NULL);
vlc_object_release (aout);
}
......@@ -397,8 +405,35 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt)
return -1;
}
/* Fill Stereo mode choices */
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 (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");
}
var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
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);
}
/* The user may have selected a different channels configuration. */
var_AddCallback (aout, "stereo-mode", StereoModeCallback, NULL);
switch (var_GetInteger (aout, "stereo-mode"))
{
case AOUT_VAR_CHAN_RSTEREO:
......@@ -417,41 +452,16 @@ 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_PHYSMASK)
!= AOUT_CHANS_STEREO)
break;
vlc_value_t val, txt;
val.i_int = 0;
var_Change (aout, "stereo-mode", VLC_VAR_DELCHOICE, &val, NULL);
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);
var_Change (aout, "stereo-mode", VLC_VAR_SETVALUE, &val, NULL);
val.i_int = AOUT_VAR_CHAN_LEFT;
txt.psz_string = _("Left");
var_Change (aout, "stereo-mode", VLC_VAR_ADDCHOICE, &val, &txt);
if (fmt->i_original_channels & AOUT_CHAN_DUALMONO)
{ /* Go directly to the left channel. */
fmt->i_original_channels = AOUT_CHAN_LEFT;
val.i_int = AOUT_VAR_CHAN_LEFT;
var_Change (aout, "stereo-mode", VLC_VAR_SETVALUE, &val, NULL);
}
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);
}
else
var_Change (aout, "stereo-mode", VLC_VAR_SETVALUE, &default_val,
NULL);
break;
}
aout_FormatPrepare (fmt);
......@@ -470,7 +480,6 @@ void aout_OutputDelete (audio_output_t *aout)
{
aout_OutputAssertLocked (aout);
var_DelCallback (aout, "stereo-mode", StereoModeCallback, NULL);
if (aout->stop != NULL)
aout->stop (aout);
}
......
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