[vlc-devel] commit: skins2: work on equalizer (Erwan Tulou )
git version control
git at videolan.org
Sun Sep 20 00:11:07 CEST 2009
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sat Sep 19 23:23:19 2009 +0200| [1e0a0540aab519729d969b96972fd26b0334caf2] | committer: 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).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1e0a0540aab519729d969b96972fd26b0334caf2
---
modules/gui/skins2/commands/cmd_audio.cpp | 1 +
modules/gui/skins2/src/vlcproc.cpp | 94 +++++++++++++++++-----------
modules/gui/skins2/src/vlcproc.hpp | 4 +
3 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/modules/gui/skins2/commands/cmd_audio.cpp b/modules/gui/skins2/commands/cmd_audio.cpp
index dc8d13e..ae7c4b7 100644
--- a/modules/gui/skins2/commands/cmd_audio.cpp
+++ b/modules/gui/skins2/commands/cmd_audio.cpp
@@ -31,6 +31,7 @@
void CmdSetEqualizer::execute()
{
aout_EnableFilter( getIntf(), "equalizer", m_enable );
+ VlcProc::instance( getIntf() )->update_equalizer();
}
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 241efec..e7ad990 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -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 );
}
diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp
index 5556c15..8156577 100644
--- a/modules/gui/skins2/src/vlcproc.hpp
+++ b/modules/gui/skins2/src/vlcproc.hpp
@@ -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
More information about the vlc-devel
mailing list