Commit 1e0a0540 authored by Erwan Tulou's avatar Erwan Tulou

skins2: work on equalizer

This patch tries to make the equalizer work in all cases.
It takes into account aout reuse, and add/remove callbacks to match the equalizer audio-filter implementation. (variables created in a filter but attached to the aout parent).
parent 8c8ae041
......@@ -31,6 +31,7 @@
void CmdSetEqualizer::execute()
{
aout_EnableFilter( getIntf(), "equalizer", m_enable );
VlcProc::instance( getIntf() )->update_equalizer();
}
......@@ -74,7 +74,8 @@ void VlcProc::destroy( intf_thread_t *pIntf )
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
m_pVout( NULL ), m_pAout( NULL ), m_bEqualizer_started( false ),
m_cmdManage( this )
{
// Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf );
......@@ -575,52 +576,49 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
case INPUT_EVENT_AOUT:
{
char *pFilters;
aout_instance_t* pAout = input_GetAout( pInput );
if( pAout )
// end of input or aout reuse (nothing to do)
if( !pAout || pAout == m_pAout )
{
if( pAout )
vlc_object_release( pAout );
break;
}
// remove previous Aout if any
if( m_pAout )
{
if( m_pAout )
var_DelCallback( m_pAout, "audio-filter",
onGenericCallback, this );
if( m_bEqualizer_started )
{
var_DelCallback( m_pAout, "audio-filter",
onGenericCallback, this );
var_DelCallback( m_pAout, "equalizer-bands",
onEqBandsChange, this );
var_DelCallback( m_pAout, "equalizer-preamp",
onEqPreampChange, this );
vlc_object_release( m_pAout );
m_pAout = NULL;
}
vlc_object_release( m_pAout );
m_pAout = NULL;
m_bEqualizer_started = false;
}
var_AddCallback( pAout, "audio-filter",
onGenericCallback, this );
// New Aout (addCallbacks)
var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
free( pFilters );
pVarEqualizer->set( b_equalizer );
if( b_equalizer )
{
var_AddCallback( pAout, "equalizer-bands",
onEqBandsChange, this );
var_AddCallback( pAout, "equalizer-preamp",
onEqPreampChange, this );
m_pAout = pAout;
pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
}
else
{
if( m_pAout )
{
var_DelCallback( m_pAout, "audio-filter",
onGenericCallback, this );
var_DelCallback( m_pAout, "equalizer-bands",
onEqBandsChange, this );
var_DelCallback( m_pAout, "equalizer-preamp",
onEqPreampChange, this );
vlc_object_release( m_pAout );
m_pAout = NULL;
}
// Get the audio filters
pFilters = config_GetPsz( getIntf(), "audio-filter" );
m_bEqualizer_started = true;
}
// Refresh the equalizer variable
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
pVarEqualizer->set( b_equalizer );
free( pFilters );
m_pAout = pAout;
break;
}
......@@ -720,15 +718,19 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
aout_instance_t* pAout = (aout_instance_t*) p_obj;
char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
char *pFilters = newVal.psz_string;
// Refresh the equalizer variable
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
pVarEqualizer->set( b_equalizer );
free( pFilters );
if( b_equalizer && !m_bEqualizer_started )
{
var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
m_bEqualizer_started = true;
}
}
void VlcProc::reset_input()
......@@ -801,5 +803,23 @@ void VlcProc::init_variables()
// Set the mute variable
VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
pVarMute->set( volume == 0 );
// Set the equalizer variable
update_equalizer();
}
void VlcProc::update_equalizer()
{
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
char *pFilters;
if( m_pAout )
pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
else
pFilters = config_GetPsz( getIntf(), "audio-filter" );
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
free( pFilters );
pVarEqualizer->set( b_equalizer );
}
......@@ -87,6 +87,9 @@ class VlcProc: public SkinObject
/// Indicate whether the embedded video output is currently used
bool isVoutUsed() const { return m_pVout != NULL; }
/// update equalizer
void update_equalizer( );
void on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
......@@ -148,6 +151,7 @@ class VlcProc: public SkinObject
vout_thread_t *m_pVout;
/// Audio output
aout_instance_t *m_pAout;
bool m_bEqualizer_started;
/**
* Poll VLC internals to update the status (volume, current time in
......
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