utils/var_tree.cpp \
utils/var_tree.hpp \
\
+ vars/equalizer.cpp \
+ vars/equalizer.hpp \
vars/playlist.cpp \
vars/playlist.hpp \
vars/playtree.cpp \
}
-void AsyncQueue::push( const CmdGenericPtr &rcCommand )
+void AsyncQueue::push( const CmdGenericPtr &rcCommand, bool removePrev )
{
+ if( removePrev )
+ {
+ // Remove the commands of the same type
+ remove( rcCommand.get()->getType() );
+ }
m_cmdList.push_back( rcCommand );
}
/// Destroy the instance of AsyncQueue
static void destroy( intf_thread_t *pIntf );
- /// Add a command in the queue
- void push( const CmdGenericPtr &rcCommand );
+ /// Add a command in the queue, after having removed the commands
+ /// of the same type already in the queue if needed
+ void push( const CmdGenericPtr &rcCommand, bool removePrev = true );
/// Remove the commands of the given type
void remove( const string &rType );
#include "cmd_vars.hpp"
#include "../src/vlcproc.hpp"
#include "../utils/var_text.hpp"
+#include "../vars/equalizer.hpp"
#include "../vars/playlist.hpp"
#include "../vars/playtree.hpp"
m_rText.set( m_value );
}
+
+void CmdSetEqBands::execute()
+{
+ // Change the equalizer bands
+ m_rEqBands.set( m_value );
+}
+
#include "cmd_generic.hpp"
#include "../utils/ustring.hpp"
+class EqualizerBands;
class VarText;
/// Command to notify the playlist of a change
};
+/// Command to set the equalizerbands
+class CmdSetEqBands: public CmdGeneric
+{
+ public:
+ CmdSetEqBands( intf_thread_t *pIntf, EqualizerBands &rEqBands,
+ const string &rValue ):
+ CmdGeneric( pIntf ), m_rEqBands( rEqBands ), m_value( rValue ) {}
+ virtual ~CmdSetEqBands() {}
+
+ /// 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 bands"; }
+
+ private:
+ /// Equalizer variable to set
+ EqualizerBands &m_rEqBands;
+ /// Value to set
+ const string m_value;
+};
+
+
#endif
newWidth, newHeight );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( m_pParent->getIntf() );
- pQueue->remove( "resize" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
newHeight );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
- pQueue->remove( "resize" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
- pQueue->remove( "change skin" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
}
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
- pQueue->remove( "load playlist" );
- pQueue->remove( "load playtree" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
}
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pIntf );
- pQueue->remove( "load playlist" );
- pQueue->remove( "load playtree" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
}
CmdChangeSkin *pCmd = new CmdChangeSkin( pThis->getIntf(),
newval.psz_string );
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "change skin" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
#include <vlc/aout.h>
#include <vlc/vout.h>
+#include <aout_internal.h>
#include "vlcproc.hpp"
#include "os_factory.hpp"
#include "../commands/cmd_resize.hpp"
#include "../commands/cmd_vars.hpp"
#include "../utils/var_bool.hpp"
+#include <sstream>
VlcProc *VlcProc::instance( intf_thread_t *pIntf )
}
-VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVout( NULL ),
- m_cmdManage( this ), m_varVoutSize( pIntf )
+VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
+ 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 );
m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
+ // Register the equalizer bands
+ for( int i = 0; i < EqualizerBands::kNbBands; i++)
+ {
+ stringstream ss;
+ ss << "equalizer.band(" << i << ")";
+ pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
+ }
+
// XXX WARNING XXX
// The object variable callbacks are called from other VLC threads,
// so they must put commands in the queue and NOT do anything else
// Get the VLC variables
StreamTime *pTime = (StreamTime*)m_cVarTime.get();
- Volume *pVolume = (Volume*)m_cVarVolume.get();
VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
- VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
- // Refresh sound volume
- audio_volume_t volume;
- aout_VolumeGet( getIntf(), &volume );
- pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
- // Set the mute variable
- pVarMute->set( volume == 0 );
+ // Refresh audio variables
+ refreshAudio();
- // Update the input
+ // Update the input
if( getIntf()->p_sys->p_input == NULL )
{
getIntf()->p_sys->p_input = (input_thread_t *)vlc_object_find(
}
+void VlcProc::refreshAudio()
+{
+ // 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 != m_pAout )
+ {
+ // Register the equalizer callback
+ if( !var_AddCallback( pAout, "equalizer-bands",
+ onEqBandsChange, this ) )
+ {
+ m_pAout = pAout;
+
+ //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
+ }
+ }
+ vlc_object_release( pAout );
+ }
+
+ // Refresh sound volume
+ audio_volume_t volume;
+ aout_VolumeGet( getIntf(), &volume );
+ Volume *pVolume = (Volume*)m_cVarVolume.get();
+ pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
+
+ // Set the mute variable
+ VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
+ pVarMute->set( volume == 0 );
+}
+
+
int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam )
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "notify playlist" );
- pQueue->remove( "playtree changed" );
pQueue->push( CmdGenericPtr( pCmd ) );
pQueue->push( CmdGenericPtr( pCmdTree ) );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "raise all windows" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "notify playlist" );
- pQueue->remove( "playtree update" );
pQueue->push( CmdGenericPtr( pCmd ) );
pQueue->push( CmdGenericPtr( pCmdTree ) );
CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
// Push the command in the asynchronous command queue
- pQueue->remove( "notify playlist" );
- pQueue->remove( "playtree changed" );
pQueue->push( CmdGenericPtr( pCmd ) );
pQueue->push( CmdGenericPtr( pCmdTree ) );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "change skin" );
pQueue->push( CmdGenericPtr( pCmd ) );
return VLC_SUCCESS;
CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
*pWidthHint, *pHeightHint );
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "resize vout" );
pQueue->push( CmdGenericPtr( pCmd ) );
return pWindow;
}
pThis->m_pVout->i_window_width,
pThis->m_pVout->i_window_height );
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "resize vout" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
}
return VLC_SUCCESS;
}
+
+int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
+ vlc_value_t oldVal, vlc_value_t newVal,
+ void *pParam )
+{
+ VlcProc *pThis = (VlcProc*)pParam;
+
+ // Post a set equalizer bands command
+ CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
+ pThis->m_varEqBands,
+ newVal.psz_string );
+ AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+ pQueue->push( CmdGenericPtr( pCmd ) );
+
+ return VLC_SUCCESS;
+}
+
#include <set>
+#include "../vars/equalizer.hpp"
#include "../vars/playlist.hpp"
#include "../vars/playtree.hpp"
#include "../vars/time.hpp"
class OSTimer;
class VarBool;
+struct aout_instance_t;
/// Singleton object handling VLC internal state and playlist
VariablePtr m_cVarSeekable;
/// Variable for the vout
VarBox m_varVoutSize;
+ /// Equalizer variable
+ EqualizerBands m_varEqBands;
/// Set of handles of vout windows
/**
set<void *> m_handleSet;
/// Vout thread
vout_thread_t *m_pVout;
+ /// Audio output
+ aout_instance_t *m_pAout;
/**
* Poll VLC internals to update the status (volume, current time in
/// Define the command that calls manage()
DEFINE_CALLBACK( VlcProc, Manage );
+ /// Refresh audio variables
+ void refreshAudio();
+
/// Update the stream name variable
void updateStreamName( playlist_t *p_playlist );
/// Callback to change a vout window
static int controlWindow( intf_thread_t *pIntf, void *pWindow,
int query, va_list args );
+
+ /// Callback for equalizer-bands variable
+ static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
+ vlc_value_t oldVal, vlc_value_t newVal,
+ void *pParam );
};
--- /dev/null
+/*****************************************************************************
+ * equalizer.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 "vlc/aout.h"
+#include "aout_internal.h"
+#include "equalizer.hpp"
+#include "../utils/var_percent.hpp"
+#include <ios>
+#include <iomanip>
+#include <sstream>
+
+
+EqualizerBands::EqualizerBands( intf_thread_t *pIntf ): SkinObject( pIntf ),
+ m_isUpdating( false )
+{
+ for( int i = 0; i < kNbBands; i++ )
+ {
+ // Create and observe the band variables
+ VarPercent *pVar = new VarPercent( pIntf );
+ m_cBands[i] = VariablePtr( pVar );
+ pVar->set( 0.5f );
+ pVar->addObserver( this );
+ }
+}
+
+
+EqualizerBands::~EqualizerBands()
+{
+ for( int i = 0; i < kNbBands; i++ )
+ {
+ ((VarPercent*)m_cBands[i].get())->delObserver( this );
+ }
+}
+
+
+void EqualizerBands::set( string bands )
+{
+ float val;
+ stringstream ss( bands );
+
+ m_isUpdating = true;
+ // Parse the string
+ for( int i = 0; i < kNbBands; i++ )
+ {
+ ss >> val;
+ // Set the band value in percent
+ ((VarPercent*)m_cBands[i].get())->set( (val + 20) / 40 );
+ }
+ m_isUpdating = false;
+}
+
+
+VariablePtr EqualizerBands::getBand( int band )
+{
+ return m_cBands[band];
+}
+
+
+void EqualizerBands::onUpdate( Subject<VarPercent> &rBand )
+{
+ // Make sure we are not called from set()
+ if (!m_isUpdating)
+ {
+ float val;
+ stringstream ss;
+ // Write one digit after the floating point
+ ss << setprecision( 1 ) << setiosflags( ios::fixed );
+
+ // Convert the band values to a string
+ val = 40 * ((VarPercent*)m_cBands[0].get())->get() - 20;
+ ss << val;
+ for( int i = 1; i < kNbBands; i++ )
+ {
+ val = 40 * ((VarPercent*)m_cBands[i].get())->get() - 20;
+ ss << " " << val;
+ }
+
+ aout_instance_t *pAout= (aout_instance_t *)vlc_object_find( getIntf(),
+ VLC_OBJECT_AOUT, FIND_ANYWHERE );
+ if( pAout )
+ {
+ // Update the audio output
+ var_SetString( pAout, "equalizer-bands", (char*)ss.str().c_str() );
+ vlc_object_release( pAout );
+ }
+ }
+}
+
--- /dev/null
+/*****************************************************************************
+ * equalizer.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 EQUALIZER_HPP
+#define EQUALIZER_HPP
+
+#include "../utils/var_percent.hpp"
+#include <string>
+
+
+/// Variable for graphical equalizer
+class EqualizerBands: public SkinObject, public Observer<VarPercent>
+{
+ public:
+ /// Number of bands
+ static const int kNbBands = 10;
+
+ EqualizerBands( intf_thread_t *pIntf );
+ virtual ~EqualizerBands();
+
+ /// Set the equalizer bands from a configuration string,
+ /// e.g. "1 5.2 -3.6 0 0 2.5 0 0 0 0"
+ void set( string bands );
+
+ /// Return the variable for a specific band
+ VariablePtr getBand( int band );
+
+ private:
+ /// Array of equalizer bands
+ VariablePtr m_cBands[kNbBands];
+ /// Flag set when an update is in progress
+ bool m_isUpdating;
+
+ /// Callback for band updates
+ virtual void onUpdate( Subject<VarPercent> &rBand );
+};
+
+
+#endif