From eb4bf298662632e8db5da3c03b5e4eaaf55b2aa6 Mon Sep 17 00:00:00 2001 From: Cyril Deguet Date: Sun, 27 Nov 2005 16:01:53 +0000 Subject: [PATCH] * all: added a new variable "equalizer.preamp" (self-explanatory ;) in skins * winamp2.xml: added preamp slider and fixed offsets --- modules/gui/skins2/commands/cmd_vars.cpp | 6 +++++ modules/gui/skins2/commands/cmd_vars.hpp | 24 +++++++++++++++++++ modules/gui/skins2/src/vlcproc.cpp | 26 +++++++++++++++++--- modules/gui/skins2/src/vlcproc.hpp | 10 ++++++-- modules/gui/skins2/vars/equalizer.cpp | 30 +++++++++++++++++++++++- modules/gui/skins2/vars/equalizer.hpp | 13 ++++++++++ modules/gui/skins2/vars/time.hpp | 4 ++-- share/skins2/winamp2.xml | 23 ++++++++++-------- 8 files changed, 118 insertions(+), 18 deletions(-) diff --git a/modules/gui/skins2/commands/cmd_vars.cpp b/modules/gui/skins2/commands/cmd_vars.cpp index 9c846f0d70..b64ede8be1 100644 --- a/modules/gui/skins2/commands/cmd_vars.cpp +++ b/modules/gui/skins2/commands/cmd_vars.cpp @@ -65,3 +65,9 @@ void CmdSetEqBands::execute() m_rEqBands.set( m_value ); } + +void CmdSetEqPreamp::execute() +{ + // Change the preamp variable + m_rPreamp.set( m_value, false ); +} diff --git a/modules/gui/skins2/commands/cmd_vars.hpp b/modules/gui/skins2/commands/cmd_vars.hpp index de31378a4c..a2445ed0de 100644 --- a/modules/gui/skins2/commands/cmd_vars.hpp +++ b/modules/gui/skins2/commands/cmd_vars.hpp @@ -28,6 +28,7 @@ #include "../utils/ustring.hpp" class EqualizerBands; +class EqualizerPreamp; class VarText; /// Command to notify the playlist of a change @@ -79,6 +80,29 @@ class CmdSetText: public CmdGeneric }; +/// Command to set the equalizer preamp +class CmdSetEqPreamp: public CmdGeneric +{ + public: + CmdSetEqPreamp( intf_thread_t *pIntf, EqualizerPreamp &rPreamp, + float value ): + CmdGeneric( pIntf ), m_rPreamp( rPreamp ), m_value( value ) {} + virtual ~CmdSetEqPreamp() {} + + /// 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 preamp"; } + + private: + /// Preamp variable to set + EqualizerPreamp &m_rPreamp; + /// Value to set + float m_value; +}; + + /// Command to set the equalizerbands class CmdSetEqBands: public CmdGeneric { diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp index 5b25e977f7..d86436e01a 100644 --- a/modules/gui/skins2/src/vlcproc.cpp +++ b/modules/gui/skins2/src/vlcproc.cpp @@ -5,7 +5,7 @@ * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière + * Olivier Teuli�e * * 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 @@ -98,6 +98,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" ) REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" ) REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" ) + REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" ) #undef REGISTER_VAR m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) ); pVarManager->registerVar( m_cVarStreamName, "streamName" ); @@ -304,9 +305,11 @@ void VlcProc::refreshAudio() { if( pAout != m_pAout ) { - // Register the equalizer callback + // Register the equalizer callbacks if( !var_AddCallback( pAout, "equalizer-bands", - onEqBandsChange, this ) ) + onEqBandsChange, this ) && + !var_AddCallback( pAout, "equalizer-preamp", + onEqPreampChange, this ) ) { m_pAout = pAout; //char * psz_bands = var_GetString( p_aout, "equalizer-bands" ); @@ -567,3 +570,20 @@ int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable, return VLC_SUCCESS; } + +int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable, + vlc_value_t oldVal, vlc_value_t newVal, + void *pParam ) +{ + VlcProc *pThis = (VlcProc*)pParam; + EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get()); + + // Post a set preamp command + CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp, + (newVal.f_float + 20.0) / 40.0 ); + AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() ); + pQueue->push( CmdGenericPtr( pCmd ) ); + + return VLC_SUCCESS; +} + diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp index 8d0113fd80..16e65804e5 100644 --- a/modules/gui/skins2/src/vlcproc.hpp +++ b/modules/gui/skins2/src/vlcproc.hpp @@ -5,7 +5,7 @@ * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière + * Olivier Teuli�e * * 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 @@ -119,8 +119,9 @@ class VlcProc: public SkinObject VariablePtr m_cVarSeekable; /// Variable for the vout VarBox m_varVoutSize; - /// Equalizer variable + /// Equalizer variables EqualizerBands m_varEqBands; + VariablePtr m_cVarEqPreamp; VariablePtr m_cVarEqualizer; /// Set of handles of vout windows @@ -194,6 +195,11 @@ class VlcProc: public SkinObject static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable, vlc_value_t oldVal, vlc_value_t newVal, void *pParam ); + + /// Callback for equalizer-preamp variable + static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable, + vlc_value_t oldVal, vlc_value_t newVal, + void *pParam ); }; diff --git a/modules/gui/skins2/vars/equalizer.cpp b/modules/gui/skins2/vars/equalizer.cpp index 27b23b1c6c..87fca34fcb 100644 --- a/modules/gui/skins2/vars/equalizer.cpp +++ b/modules/gui/skins2/vars/equalizer.cpp @@ -96,7 +96,7 @@ void EqualizerBands::onUpdate( Subject &rBand ) ss << " " << val; } - 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 ); char *bands = (char*)ss.str().c_str(); config_PutPsz( getIntf(), "equalizer-bands", bands ); @@ -109,3 +109,31 @@ void EqualizerBands::onUpdate( Subject &rBand ) } } + +EqualizerPreamp::EqualizerPreamp( intf_thread_t *pIntf ): VarPercent( pIntf ) +{ + // Initial value + VarPercent::set( 0.8 ); +} + + +void EqualizerPreamp::set( float percentage, bool updateVLC ) +{ + VarPercent::set( percentage ); + + // Avoid infinite loop + if( updateVLC ) + { + float val = 40 * percentage - 20; + + aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(), + VLC_OBJECT_AOUT, FIND_ANYWHERE ); + config_PutFloat( getIntf(), "equalizer-preamp", val ); + if( pAout ) + { + // Update the audio output + var_SetFloat( pAout, "equalizer-preamp", val ); + vlc_object_release( pAout ); + } + } +} diff --git a/modules/gui/skins2/vars/equalizer.hpp b/modules/gui/skins2/vars/equalizer.hpp index 08f45bca67..48bc031b78 100644 --- a/modules/gui/skins2/vars/equalizer.hpp +++ b/modules/gui/skins2/vars/equalizer.hpp @@ -56,4 +56,17 @@ class EqualizerBands: public SkinObject, public Observer }; +/// Variable for equalizer preamp +class EqualizerPreamp: public VarPercent +{ + public: + EqualizerPreamp( intf_thread_t *pIntf ); + virtual ~EqualizerPreamp() {} + + virtual void set( float percentage, bool updateVLC ); + + void set( float percentage ) { set( percentage, true ); } +}; + + #endif diff --git a/modules/gui/skins2/vars/time.hpp b/modules/gui/skins2/vars/time.hpp index 0292c43cc8..5768587a11 100644 --- a/modules/gui/skins2/vars/time.hpp +++ b/modules/gui/skins2/vars/time.hpp @@ -5,7 +5,7 @@ * $Id$ * * Authors: Cyril Deguet - * Olivier Teulière + * Olivier Teuli�e * * 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 @@ -28,7 +28,7 @@ #include "../utils/var_percent.hpp" #include -/// Variable for VLC strem time +/// Variable for VLC stream time class StreamTime: public VarPercent { public: diff --git a/share/skins2/winamp2.xml b/share/skins2/winamp2.xml index 58380a2151..fdd88a0692 100644 --- a/share/skins2/winamp2.xml +++ b/share/skins2/winamp2.xml @@ -248,34 +248,37 @@