Commit 13a000e7 authored by Cyril Deguet's avatar Cyril Deguet

* all: added a variable "equalizer.isEnabled" and commands

 "equalizer.enable()" and "equalizer.disable()" to enable
  or disable the equalizer audio filter.
  + small fixes
parent 4ea25c4d
...@@ -3,6 +3,8 @@ SOURCES_skins2 = \ ...@@ -3,6 +3,8 @@ SOURCES_skins2 = \
commands/async_queue.hpp \ commands/async_queue.hpp \
commands/cmd_add_item.cpp \ commands/cmd_add_item.cpp \
commands/cmd_add_item.hpp \ commands/cmd_add_item.hpp \
commands/cmd_audio.cpp \
commands/cmd_audio.hpp \
commands/cmd_dummy.hpp \ commands/cmd_dummy.hpp \
commands/cmd_generic.hpp \ commands/cmd_generic.hpp \
commands/cmd_change_skin.cpp \ commands/cmd_change_skin.cpp \
......
/*****************************************************************************
* 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() );
}
}
/*****************************************************************************
* 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
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "interpreter.hpp" #include "interpreter.hpp"
#include "expr_evaluator.hpp" #include "expr_evaluator.hpp"
#include "../commands/cmd_audio.hpp"
#include "../commands/cmd_muxer.hpp" #include "../commands/cmd_muxer.hpp"
#include "../commands/cmd_playlist.hpp" #include "../commands/cmd_playlist.hpp"
#include "../commands/cmd_playtree.hpp" #include "../commands/cmd_playtree.hpp"
...@@ -113,6 +114,10 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) ...@@ -113,6 +114,10 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf )
REGISTER_CMD( "vlc.minimize()", CmdMinimize ) REGISTER_CMD( "vlc.minimize()", CmdMinimize )
REGISTER_CMD( "vlc.onTop()", CmdOnTop ) REGISTER_CMD( "vlc.onTop()", CmdOnTop )
REGISTER_CMD( "vlc.quit()", CmdQuit ) 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 // Register the constant bool variables in the var manager
VarManager *pVarManager = VarManager::instance( getIntf() ); VarManager *pVarManager = VarManager::instance( getIntf() );
......
...@@ -64,8 +64,8 @@ void VlcProc::destroy( intf_thread_t *pIntf ) ...@@ -64,8 +64,8 @@ void VlcProc::destroy( intf_thread_t *pIntf )
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_varVoutSize( pIntf ), m_varEqBands( pIntf ), m_pVout( NULL ), m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
m_pAout( NULL ), m_cmdManage( this ) m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
{ {
// Create a timer to poll the status of the vlc // Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf ); OSFactory *pOsFactory = OSFactory::instance( pIntf );
...@@ -97,6 +97,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), ...@@ -97,6 +97,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" ) REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" ) REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" ) REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
#undef REGISTER_VAR #undef REGISTER_VAR
m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) ); m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamName, "streamName" ); pVarManager->registerVar( m_cVarStreamName, "streamName" );
...@@ -294,10 +295,12 @@ void VlcProc::CmdManage::execute() ...@@ -294,10 +295,12 @@ void VlcProc::CmdManage::execute()
void VlcProc::refreshAudio() void VlcProc::refreshAudio()
{ {
char *pFilters = NULL;
// Check if the audio output has changed // Check if the audio output has changed
aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(), aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
VLC_OBJECT_AOUT, FIND_ANYWHERE ); VLC_OBJECT_AOUT, FIND_ANYWHERE );
if( pAout != NULL ) if( pAout )
{ {
if( pAout != m_pAout ) if( pAout != m_pAout )
{ {
...@@ -306,12 +309,18 @@ void VlcProc::refreshAudio() ...@@ -306,12 +309,18 @@ void VlcProc::refreshAudio()
onEqBandsChange, this ) ) onEqBandsChange, this ) )
{ {
m_pAout = pAout; m_pAout = pAout;
//char * psz_bands = var_GetString( p_aout, "equalizer-bands" ); //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
} }
} }
// Get the audio filters
pFilters = var_GetString( pAout, "audio-filter" );
vlc_object_release( pAout ); vlc_object_release( pAout );
} }
else
{
// Get the audio filters
pFilters = config_GetPsz( getIntf(), "audio-filter" );
}
// Refresh sound volume // Refresh sound volume
audio_volume_t volume; audio_volume_t volume;
...@@ -322,6 +331,10 @@ void VlcProc::refreshAudio() ...@@ -322,6 +331,10 @@ void VlcProc::refreshAudio()
// Set the mute variable // Set the mute variable
VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get(); VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
pVarMute->set( volume == 0 ); pVarMute->set( volume == 0 );
// Refresh the equalizer variable
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
} }
......
...@@ -121,6 +121,7 @@ class VlcProc: public SkinObject ...@@ -121,6 +121,7 @@ class VlcProc: public SkinObject
VarBox m_varVoutSize; VarBox m_varVoutSize;
/// Equalizer variable /// Equalizer variable
EqualizerBands m_varEqBands; EqualizerBands m_varEqBands;
VariablePtr m_cVarEqualizer;
/// Set of handles of vout windows /// Set of handles of vout windows
/** /**
......
...@@ -98,10 +98,12 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand ) ...@@ -98,10 +98,12 @@ void EqualizerBands::onUpdate( Subject<VarPercent> &rBand )
aout_instance_t *pAout= (aout_instance_t *)vlc_object_find( getIntf(), aout_instance_t *pAout= (aout_instance_t *)vlc_object_find( getIntf(),
VLC_OBJECT_AOUT, FIND_ANYWHERE ); VLC_OBJECT_AOUT, FIND_ANYWHERE );
char *bands = (char*)ss.str().c_str();
config_PutPsz( getIntf(), "equalizer-bands", bands );
if( pAout ) if( pAout )
{ {
// Update the audio output // Update the audio output
var_SetString( pAout, "equalizer-bands", (char*)ss.str().c_str() ); var_SetString( pAout, "equalizer-bands", bands );
vlc_object_release( pAout ); vlc_object_release( pAout );
} }
} }
......
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