[vlc-commits] skins2: simplify equalizer initialization

Erwan Tulou git at videolan.org
Thu Apr 25 22:59:33 CEST 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Apr 25 22:49:52 2013 +0200| [56d4e908e1b71fc6161622701d1cf0db64e57aa6] | committer: Erwan Tulou

skins2: simplify equalizer initialization

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=56d4e908e1b71fc6161622701d1cf0db64e57aa6
---

 modules/gui/skins2/commands/cmd_audio.cpp |    1 -
 modules/gui/skins2/src/vlcproc.cpp        |  112 ++++++++++++-----------------
 modules/gui/skins2/src/vlcproc.hpp        |    6 +-
 3 files changed, 48 insertions(+), 71 deletions(-)

diff --git a/modules/gui/skins2/commands/cmd_audio.cpp b/modules/gui/skins2/commands/cmd_audio.cpp
index 3c54742..a74198d 100644
--- a/modules/gui/skins2/commands/cmd_audio.cpp
+++ b/modules/gui/skins2/commands/cmd_audio.cpp
@@ -32,7 +32,6 @@ void CmdSetEqualizer::execute()
     playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
 
     playlist_EnableAudioFilter( pPlaylist, "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 e52e54d..7aa1022 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -82,7 +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_varEqBands( pIntf ), m_pVout( NULL )
 {
     // Create and register VLC variables
     VarManager *pVarManager = VarManager::instance( getIntf() );
@@ -189,11 +189,6 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
 
 VlcProc::~VlcProc()
 {
-    if( m_pAout )
-    {
-        vlc_object_release( m_pAout );
-        m_pAout = NULL;
-    }
     if( m_pVout )
     {
         vlc_object_release( m_pVout );
@@ -533,57 +528,6 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
             break;
         }
 
-        case INPUT_EVENT_AOUT:
-        {
-            audio_output_t* pAout = input_GetAout( pInput );
-
-            // 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 )
-            {
-                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;
-            }
-
-            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, "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 );
-            break;
-        }
-
         case INPUT_EVENT_CHAPTER:
         {
             vlc_value_t chapters_count;
@@ -779,7 +723,7 @@ void VlcProc::init_variables()
 
     SET_BOOL( m_cVarStopped, true );
 
-    update_equalizer();
+    init_equalizer();
 }
 
 
@@ -815,19 +759,55 @@ void VlcProc::update_current_input()
     }
 }
 
-void VlcProc::update_equalizer()
+void VlcProc::init_equalizer()
 {
+    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
+    audio_output_t* pAout = playlist_GetAout( pPlaylist );
+    if( pAout )
+    {
+        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, "equalizer-bands",
+                         onEqBandsChange, this );
+        var_AddCallback( pAout, "equalizer-preamp",
+                         onEqPreampChange, this );
+    }
 
-    char *pFilters;
-    if( m_pAout )
-        pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
-    else
-        pFilters = var_InheritString( getIntf(), "audio-filter" );
-
+    // is equalizer enabled ?
+    char *pFilters = pAout ?
+                   var_GetNonEmptyString( pAout, "audio-filter" ) :
+                   var_InheritString( getIntf(), "audio-filter" );
     bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
     free( pFilters );
-
     SET_BOOL( m_cVarEqualizer, b_equalizer );
+
+    // retrieve initial bands
+    char* bands = pAout ?
+                  var_GetString( pAout, "equalizer-bands" ) :
+                  var_InheritString( getIntf(), "equalizer-bands" );
+    if( bands )
+    {
+        m_varEqBands.set( bands );
+        free( bands );
+    }
+
+    // retrieve initial preamp
+    float preamp = pAout ?
+                   var_GetFloat( pAout, "equalizer-preamp" ) :
+                   var_InheritFloat( getIntf(), "equalizer-preamp" );
+    EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)m_cVarEqPreamp.get();
+    pVarPreamp->set( (preamp + 20.0) / 40.0 );
+
+    if( pAout )
+        vlc_object_release( pAout);
 }
 
 void VlcProc::setFullscreenVar( bool b_fullscreen )
diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp
index bacb019..76ebe1a 100644
--- a/modules/gui/skins2/src/vlcproc.hpp
+++ b/modules/gui/skins2/src/vlcproc.hpp
@@ -95,8 +95,8 @@ public:
     /// Indicate whether the embedded video output is currently used
     bool isVoutUsed() const { return m_pVout != NULL; }
 
-    /// update equalizer
-    void update_equalizer( );
+    /// initialize equalizer
+    void init_equalizer( );
 
     /// update global variables for the current input
     void update_current_input( );
@@ -164,8 +164,6 @@ private:
 
     /// Vout thread
     vout_thread_t *m_pVout;
-    /// Audio output
-    audio_output_t *m_pAout;
 
     // reset variables when input is over
     void reset_input();



More information about the vlc-commits mailing list