]> git.sesse.net Git - vlc/commitdiff
* all: added a variable "equalizer.isEnabled" and commands
authorCyril Deguet <asmax@videolan.org>
Sat, 5 Nov 2005 11:54:38 +0000 (11:54 +0000)
committerCyril Deguet <asmax@videolan.org>
Sat, 5 Nov 2005 11:54:38 +0000 (11:54 +0000)
 "equalizer.enable()" and "equalizer.disable()" to enable
  or disable the equalizer audio filter.
  + small fixes

modules/gui/skins2/Modules.am
modules/gui/skins2/commands/cmd_audio.cpp [new file with mode: 0644]
modules/gui/skins2/commands/cmd_audio.hpp [new file with mode: 0644]
modules/gui/skins2/parser/interpreter.cpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vlcproc.hpp
modules/gui/skins2/vars/equalizer.cpp

index 9246346ce11c963e51b9b8961a42cc641172976a..530acf061ca0895fa308c3a1742bd3121a0bbbd2 100644 (file)
@@ -3,6 +3,8 @@ SOURCES_skins2 = \
        commands/async_queue.hpp \
        commands/cmd_add_item.cpp \
        commands/cmd_add_item.hpp \
+       commands/cmd_audio.cpp \
+       commands/cmd_audio.hpp \
        commands/cmd_dummy.hpp \
        commands/cmd_generic.hpp \
        commands/cmd_change_skin.cpp \
diff --git a/modules/gui/skins2/commands/cmd_audio.cpp b/modules/gui/skins2/commands/cmd_audio.cpp
new file mode 100644 (file)
index 0000000..66d67cb
--- /dev/null
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * cmd_audio.cpp
+ *****************************************************************************
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include "cmd_audio.hpp"
+#include <vlc/aout.h>
+#include "aout_internal.h"
+#include <string>
+
+void CmdSetEqualizer::execute()
+{
+    // Get the audio output
+    aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
+        VLC_OBJECT_AOUT, FIND_ANYWHERE );
+
+    // XXX
+    string filters;
+    if( m_enable)
+    {
+        filters = "equalizer";
+    }
+
+    if( pAout )
+    {
+        var_SetString( pAout, "audio-filter", (char*)filters.c_str() );
+        for( int i = 0; i < pAout->i_nb_inputs; i++ )
+        {
+            pAout->pp_inputs[i]->b_restart = VLC_TRUE;
+        }
+        vlc_object_release( pAout );
+    }
+    else
+    {
+        config_PutPsz( getIntf(), "audio-filter", filters.c_str() );
+    }
+}
+
diff --git a/modules/gui/skins2/commands/cmd_audio.hpp b/modules/gui/skins2/commands/cmd_audio.hpp
new file mode 100644 (file)
index 0000000..7ecbbd8
--- /dev/null
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * cmd_audio.hpp
+ *****************************************************************************
+ * Copyright (C) 2003 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Cyril Deguet     <asmax@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#ifndef CMD_AUDIO_HPP
+#define CMD_AUDIO_HPP
+
+#include "cmd_generic.hpp"
+
+/// Command to enable/disable the equalizer
+class CmdSetEqualizer: public CmdGeneric
+{
+    public:
+        CmdSetEqualizer( intf_thread_t *pIntf, bool iEnable ):
+            CmdGeneric( pIntf ), m_enable( iEnable ) {}
+        virtual ~CmdSetEqualizer() {}
+
+        /// This method does the real job of the command
+        virtual void execute();
+
+        /// Return the type of the command
+        virtual string getType() const { return "set equalizer"; }
+
+    private:
+        /// Enable or disable the equalizer
+        bool m_enable;
+};
+
+
+#endif
index b97a4231cc175297a680fdf6682839c9f6b1383c..02c9701682fbb9f3a8885117a8e5064b3f783b9e 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "interpreter.hpp"
 #include "expr_evaluator.hpp"
+#include "../commands/cmd_audio.hpp"
 #include "../commands/cmd_muxer.hpp"
 #include "../commands/cmd_playlist.hpp"
 #include "../commands/cmd_playtree.hpp"
@@ -113,6 +114,10 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
     REGISTER_CMD( "vlc.minimize()", CmdMinimize )
     REGISTER_CMD( "vlc.onTop()", CmdOnTop )
     REGISTER_CMD( "vlc.quit()", CmdQuit )
+    m_commandMap["equalizer.enable()"] =
+        CmdGenericPtr( new CmdSetEqualizer( getIntf(), true ) );
+    m_commandMap["equalizer.disable()"] =
+        CmdGenericPtr( new CmdSetEqualizer( getIntf(), false ) );
 
     // Register the constant bool variables in the var manager
     VarManager *pVarManager = VarManager::instance( getIntf() );
index 7c7a36c0822140ea3c356e1f78f8f1a5ec10a0b3..f5c7a0116bd8659f8fbd5ec0d9b7ca7b09944b53 100644 (file)
@@ -64,8 +64,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_varVoutSize( pIntf ), m_varEqBands( pIntf ),
+    m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
 {
     // Create a timer to poll the status of the vlc
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
@@ -97,6 +97,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
     REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
+    REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
 #undef REGISTER_VAR
     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
     pVarManager->registerVar( m_cVarStreamName, "streamName" );
@@ -294,10 +295,12 @@ void VlcProc::CmdManage::execute()
 
 void VlcProc::refreshAudio()
 {
+    char *pFilters = NULL;
+
     // Check if the audio output has changed
     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
             VLC_OBJECT_AOUT, FIND_ANYWHERE );
-    if( pAout != NULL )
+    if( pAout )
     {
         if( pAout != m_pAout )
         {
@@ -306,12 +309,18 @@ void VlcProc::refreshAudio()
                                  onEqBandsChange, this ) )
             {
                 m_pAout = pAout;
-
                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
             }
         }
+        // Get the audio filters
+        pFilters = var_GetString( pAout, "audio-filter" );
         vlc_object_release( pAout );
     }
+    else
+    {
+        // Get the audio filters
+        pFilters = config_GetPsz( getIntf(), "audio-filter" );
+    }
 
     // Refresh sound volume
     audio_volume_t volume;
@@ -322,6 +331,10 @@ void VlcProc::refreshAudio()
     // Set the mute variable
     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
     pVarMute->set( volume == 0 );
+
+    // Refresh the equalizer variable
+    VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
+    pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
 }
 
 
index 08da857c3689921246c4df55d23bd724016b9c2a..8d0113fd807bd955d6e759cddde7002d3e3e54c8 100644 (file)
@@ -121,6 +121,7 @@ class VlcProc: public SkinObject
         VarBox m_varVoutSize;
         /// Equalizer variable
         EqualizerBands m_varEqBands;
+        VariablePtr m_cVarEqualizer;
 
         /// Set of handles of vout windows
         /**
index a9eb5071f5c3191c2b0add589b5ec27693f6f72c..27b23b1c6c5e2a4af398c8f6fefa8c1d0ba1395b 100644 (file)
@@ -98,10 +98,12 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand )
 
         aout_instance_t *pAout= (aout_instance_t *)vlc_object_find( getIntf(),
                 VLC_OBJECT_AOUT, FIND_ANYWHERE );
+        char *bands = (char*)ss.str().c_str();
+        config_PutPsz( getIntf(), "equalizer-bands", bands );
         if( pAout )
         {
             // Update the audio output
-            var_SetString( pAout, "equalizer-bands", (char*)ss.str().c_str() );
+            var_SetString( pAout, "equalizer-bands", bands );
             vlc_object_release( pAout );
         }
     }