[vlc-commits] skins2: fix an equalizer issue
Erwan Tulou
git at videolan.org
Thu Apr 25 14:53:19 CEST 2013
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Apr 25 13:43:53 2013 +0200| [33707d7a2c84ca0fb2e576c154bc4290e0b0f888] | committer: Erwan Tulou
skins2: fix an equalizer issue
Create the "equalizer-bands" and "equalizer-preamp" variables if not yet
created to ensure that callbacks are added successfully.
Note that this is a hack to work around a lack of proper notification
as to when these variables are created/deleted.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=33707d7a2c84ca0fb2e576c154bc4290e0b0f888
---
modules/gui/skins2/src/vlcproc.cpp | 53 ++++++++++++++++--------------------
modules/gui/skins2/src/vlcproc.hpp | 1 -
2 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 858f692..e52e54d 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -82,8 +82,7 @@ void VlcProc::destroy( intf_thread_t *pIntf )
#define SET_VOLUME(m,v,b) ((Volume*)(m).get())->setVolume(v,b)
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
- m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ),
- m_bEqualizer_started( false )
+ m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL )
{
// Create and register VLC variables
VarManager *pVarManager = VarManager::instance( getIntf() );
@@ -551,34 +550,37 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
var_DelCallback( m_pAout, "audio-filter",
onGenericCallback, this );
- if( m_bEqualizer_started )
- {
- var_DelCallback( m_pAout, "equalizer-bands",
- onEqBandsChange, this );
- var_DelCallback( m_pAout, "equalizer-preamp",
- onEqPreampChange, 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;
- m_bEqualizer_started = false;
}
+ m_pAout = pAout;
+
+ // make sure some key variables exist !
+ // yes, this is a ugly but needed hack
+ if( !var_Type( pAout, "equalizer-bands" ) )
+ var_Create( pAout, "equalizer-bands",
+ VLC_VAR_STRING | VLC_VAR_DOINHERIT);
+ if( !var_Type( pAout, "equalizer-preamp" ) )
+ var_Create( pAout, "equalizer-preamp",
+ VLC_VAR_FLOAT | VLC_VAR_DOINHERIT);
+
// New Aout (addCallbacks)
- var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
+ var_AddCallback( pAout, "audio-filter",
+ onGenericCallback, this );
+ var_AddCallback( pAout, "equalizer-bands",
+ onEqBandsChange, this );
+ var_AddCallback( pAout, "equalizer-preamp",
+ onEqPreampChange, this );
char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
free( pFilters );
SET_BOOL( m_cVarEqualizer, b_equalizer );
- if( b_equalizer )
- {
- var_AddCallback( pAout, "equalizer-bands",
- onEqBandsChange, this );
- var_AddCallback( pAout, "equalizer-preamp",
- onEqPreampChange, this );
- m_bEqualizer_started = true;
- }
- m_pAout = pAout;
break;
}
@@ -684,19 +686,10 @@ void VlcProc::on_mute_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 )
{
- (void)newVal;
- audio_output_t* pAout = (audio_output_t*) p_obj;
-
+ (void)p_obj;
char *pFilters = newVal.psz_string;
-
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
SET_BOOL( m_cVarEqualizer, b_equalizer );
- 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::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp
index 8c18aee..bacb019 100644
--- a/modules/gui/skins2/src/vlcproc.hpp
+++ b/modules/gui/skins2/src/vlcproc.hpp
@@ -166,7 +166,6 @@ private:
vout_thread_t *m_pVout;
/// Audio output
audio_output_t *m_pAout;
- bool m_bEqualizer_started;
// reset variables when input is over
void reset_input();
More information about the vlc-commits
mailing list