Commit ebd6d41f authored by Erwan Tulou's avatar Erwan Tulou

skins2: replace polling with callbacks

parent 6ce54993
...@@ -33,10 +33,4 @@ void CmdSetEqualizer::execute() ...@@ -33,10 +33,4 @@ void CmdSetEqualizer::execute()
aout_EnableFilter( getIntf(), "equalizer", m_enable ); aout_EnableFilter( getIntf(), "equalizer", m_enable );
} }
void CmdVolumeChanged::execute()
{
VlcProc* p_VlcProc = getIntf()->p_sys->p_vlcProc;
p_VlcProc->refreshVolume();
}
...@@ -46,21 +46,4 @@ class CmdSetEqualizer: public CmdGeneric ...@@ -46,21 +46,4 @@ class CmdSetEqualizer: public CmdGeneric
}; };
/// Command to enable/disable the equalizer
class CmdVolumeChanged: public CmdGeneric
{
public:
CmdVolumeChanged( intf_thread_t *pIntf ) : CmdGeneric( pIntf ) {}
virtual ~CmdVolumeChanged() {}
/// This method does the real job of the command
virtual void execute();
/// Return the type of the command
virtual string getType() const { return "set volume"; }
private:
};
#endif #endif
/*****************************************************************************
* cmd_callbacks.hpp
*****************************************************************************
* Copyright (C) 2009 the VideoLAN team
* $Id$
*
* Author: Erwan Tulou <erwan10 aT videolan doT org >
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef CMD_CALLBACKS_HPP
#define CMD_CALLBACKS_HPP
#include "cmd_generic.hpp"
#include "../src/vlcproc.hpp"
#define ADD_COMMAND( label ) \
class Cmd_##label : public CmdGeneric \
{ \
public: \
Cmd_##label( intf_thread_t *pIntf, \
vlc_object_t *pObj, vlc_value_t newVal ) \
: CmdGeneric( pIntf ), m_pObj( pObj ), m_newVal( newVal ) \
{ \
if( m_pObj ) \
vlc_object_hold( m_pObj ); \
} \
virtual ~Cmd_##label() \
{ \
if( m_pObj ) \
vlc_object_release( m_pObj ); \
} \
\
virtual void execute() \
{ \
if( !m_pObj ) \
return; \
\
VlcProc* p_VlcProc = VlcProc::instance( getIntf() ); \
p_VlcProc->on_##label( m_pObj, m_newVal ); \
\
vlc_object_release( m_pObj ); \
m_pObj = NULL; \
} \
\
virtual string getType() const { return #label ; } \
\
private: \
vlc_object_t* m_pObj; \
vlc_value_t m_newVal; \
};
ADD_COMMAND( item_current_changed )
ADD_COMMAND( intf_event_changed )
ADD_COMMAND( bit_rate_changed )
ADD_COMMAND( sample_rate_changed )
ADD_COMMAND( random_changed )
ADD_COMMAND( loop_changed )
ADD_COMMAND( repeat_changed )
ADD_COMMAND( volume_changed )
ADD_COMMAND( audio_filter_changed )
#undef ADD_COMMAND
#endif
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "../commands/cmd_dialogs.hpp" #include "../commands/cmd_dialogs.hpp"
#include "../commands/cmd_update_item.hpp" #include "../commands/cmd_update_item.hpp"
#include "../commands/cmd_audio.hpp" #include "../commands/cmd_audio.hpp"
#include "../commands/cmd_callbacks.hpp"
#include "../utils/var_bool.hpp" #include "../utils/var_bool.hpp"
#include <sstream> #include <sstream>
...@@ -139,8 +140,18 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), ...@@ -139,8 +140,18 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
// (X11 calls are not reentrant) // (X11 calls are not reentrant)
// Called when volume sound changes // Called when volume sound changes
var_AddCallback( pIntf->p_libvlc, "volume-change", #define ADD_CALLBACK( p_object, var ) \
onVolumeChanged, this ); var_AddCallback( p_object, var, onGenericCallback, this );
ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
#undef ADD_CALLBACK
// Called when the playlist changes // Called when the playlist changes
var_AddCallback( pIntf->p_sys->p_playlist, "intf-change", var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
onIntfChange, this ); onIntfChange, this );
...@@ -176,16 +187,31 @@ VlcProc::~VlcProc() ...@@ -176,16 +187,31 @@ VlcProc::~VlcProc()
{ {
m_pTimer->stop(); m_pTimer->stop();
delete( m_pTimer ); delete( m_pTimer );
if( getIntf()->p_sys->p_input )
if( m_pAout )
{
vlc_object_release( m_pAout );
m_pAout = NULL;
}
if( m_pVout )
{
vlc_object_release( m_pVout );
m_pVout = NULL;
}
input_thread_t* pInput = getIntf()->p_sys->p_input;
if( pInput )
{ {
vlc_object_release( getIntf()->p_sys->p_input ); var_DelCallback( pInput, "intf-event", onGenericCallback, this );
var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
vlc_object_release( pInput );
getIntf()->p_sys->p_input = NULL; getIntf()->p_sys->p_input = NULL;
} }
interaction_Unregister( getIntf() ); interaction_Unregister( getIntf() );
var_DelCallback( getIntf()->p_libvlc, "volume-change",
onVolumeChanged, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change", var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
onIntfChange, this ); onIntfChange, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append", var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
...@@ -194,6 +220,8 @@ VlcProc::~VlcProc() ...@@ -194,6 +220,8 @@ VlcProc::~VlcProc()
onItemDelete, this ); onItemDelete, this );
var_DelCallback( getIntf()->p_libvlc, "intf-show", var_DelCallback( getIntf()->p_libvlc, "intf-show",
onIntfShow, this ); onIntfShow, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
onGenericCallback, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "item-current", var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
onPlaylistChange, this ); onPlaylistChange, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "item-change", var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
...@@ -215,10 +243,6 @@ void VlcProc::manage() ...@@ -215,10 +243,6 @@ void VlcProc::manage()
return; return;
} }
refreshPlaylist();
refreshAudio();
refreshInput();
} }
void VlcProc::CmdManage::execute() void VlcProc::CmdManage::execute()
...@@ -227,184 +251,6 @@ void VlcProc::CmdManage::execute() ...@@ -227,184 +251,6 @@ void VlcProc::CmdManage::execute()
m_pParent->manage(); m_pParent->manage();
} }
void VlcProc::refreshAudio()
{
char *pFilters;
aout_instance_t *pAout = NULL;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
pAout = input_GetAout( pInput );
if( pAout )
{
// Check if the audio output has changed
if( pAout != m_pAout )
{
// Register the equalizer callbacks
if( !var_AddCallback( pAout, "equalizer-bands",
onEqBandsChange, this ) &&
!var_AddCallback( pAout, "equalizer-preamp",
onEqPreampChange, this ) )
{
m_pAout = pAout;
//char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
}
}
// Get the audio filters
pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
}
else
{
// Get the audio filters
pFilters = config_GetPsz( getIntf(), "audio-filter" );
}
// Refresh the equalizer variable
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
free( pFilters );
if( pAout )
vlc_object_release( pAout );
if( pInput )
vlc_object_release( pInput );
}
void VlcProc::refreshVolume()
{
// Refresh sound volume
audio_volume_t volume;
aout_VolumeGet( getIntf()->p_sys->p_playlist, &volume );
Volume *pVolume = (Volume*)m_cVarVolume.get();
pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX , false );
// Set the mute variable
VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
pVarMute->set( volume == 0 );
}
void VlcProc::refreshPlaylist()
{
// Refresh the random variable
VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
vlc_value_t val;
var_Get( getIntf()->p_sys->p_playlist, "random", &val );
pVarRandom->set( val.b_bool != 0 );
// Refresh the loop variable
VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
pVarLoop->set( val.b_bool != 0 );
// Refresh the repeat variable
VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
pVarRepeat->set( val.b_bool != 0 );
}
void VlcProc::refreshInput()
{
StreamTime *pTime = (StreamTime*)m_cVarTime.get();
VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
// Update the input
if( getIntf()->p_sys->p_input == NULL )
{
getIntf()->p_sys->p_input =
playlist_CurrentInput( getIntf()->p_sys->p_playlist );
}
else if( getIntf()->p_sys->p_input->b_dead )
{
vlc_object_release( getIntf()->p_sys->p_input );
getIntf()->p_sys->p_input = NULL;
}
input_thread_t *pInput = getIntf()->p_sys->p_input;
if( pInput && vlc_object_alive (pInput) )
{
// Refresh time variables
vlc_value_t pos;
var_Get( pInput, "position", &pos );
pTime->set( pos.f_float, false );
pVarSeekable->set( pos.f_float != 0.0 );
// Refresh DVD detection
vlc_value_t chapters_count;
var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
&chapters_count, NULL );
pVarDvdActive->set( chapters_count.i_int > 0 );
// Get the input bitrate
int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
// Get the audio sample rate
int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
// Do we have audio
vlc_value_t audio_es;
var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
&audio_es, NULL );
pVarHasAudio->set( audio_es.i_int > 0 );
// Refresh fullscreen status
vout_thread_t *pVout = input_GetVout( pInput );
pVarHasVout->set( pVout != NULL );
if( pVout )
{
pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
vlc_object_release( pVout );
}
// Refresh play/pause status
int state = var_GetInteger( pInput, "state" );
pVarStopped->set( false );
pVarPlaying->set( state != PAUSE_S );
pVarPaused->set( state == PAUSE_S );
}
else
{
pVarSeekable->set( false );
pVarDvdActive->set( false );
pTime->set( 0, false );
pVarFullscreen->set( false );
pVarHasAudio->set( false );
pVarHasVout->set( false );
pVarStopped->set( true );
pVarPlaying->set( false );
pVarPaused->set( false );
}
}
int VlcProc::onVolumeChanged( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam )
{
VlcProc *pThis = (VlcProc*)pParam;
// Create a playtree notify command (for new style playtree)
CmdVolumeChanged *pCmd = new CmdVolumeChanged( pThis->getIntf() );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
pQueue->push( CmdGenericPtr( pCmd ) );
return VLC_SUCCESS;
}
int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable, int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal, vlc_value_t oldVal, vlc_value_t newVal,
...@@ -612,3 +458,292 @@ int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable, ...@@ -612,3 +458,292 @@ int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam )
{
VlcProc *pThis = (VlcProc*)pParam;
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
CmdGeneric *pCmd = NULL;
#define ADD_CALLBACK_ENTRY( var, label ) \
{ \
if( strcmp( pVariable, var ) == 0 ) \
pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
}
ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
ADD_CALLBACK_ENTRY( "random", random_changed )
ADD_CALLBACK_ENTRY( "loop", loop_changed )
ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
#undef ADD_CALLBACK_ENTRY
if( pCmd )
pQueue->push( CmdGenericPtr( pCmd ), false );
else
msg_Err( pObj, "no Callback entry provided for %s", pVariable );
return VLC_SUCCESS;
}
void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
input_thread_t* pInput = getIntf()->p_sys->p_input;
if( pInput )
{
var_DelCallback( pInput, "intf-event", onGenericCallback, this );
var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
vlc_object_release( pInput );
pInput = getIntf()->p_sys->p_input = NULL;
}
playlist_t * pPlaylist = getIntf()->p_sys->p_playlist;
pInput = playlist_CurrentInput( pPlaylist );
if( !pInput )
return;
var_AddCallback( pInput, "intf-event", onGenericCallback, this );
var_AddCallback( pInput, "bit-rate", onGenericCallback, this );
var_AddCallback( pInput, "sample-rate", onGenericCallback, this );
getIntf()->p_sys->p_input = pInput;
}
void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
input_thread_t* pInput = (input_thread_t*) p_obj;
StreamTime *pTime = (StreamTime*)m_cVarTime.get();
VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
if( vlc_object_alive( pInput ) )
{
switch( newVal.i_int )
{
case INPUT_EVENT_STATE:
{
int state = var_GetInteger( pInput, "state" );
pVarStopped->set( false );
pVarPlaying->set( state != PAUSE_S );
pVarPaused->set( state == PAUSE_S );
break;
}
case INPUT_EVENT_POSITION:
{
float pos = var_GetFloat( pInput, "position" );
pTime->set( pos, false );
pVarSeekable->set( pos != 0.0 );
break;
}
case INPUT_EVENT_ES:
{
// Do we have audio
vlc_value_t audio_es;
var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
&audio_es, NULL );
pVarHasAudio->set( audio_es.i_int > 0 );
break;
}
case INPUT_EVENT_VOUT:
{
vout_thread_t* pVout = input_GetVout( pInput );
pVarHasVout->set( pVout != NULL );
if( pVout )
{
pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
vlc_object_release( pVout );
}
break;
}
case INPUT_EVENT_AOUT:
{
char *pFilters;
aout_instance_t* pAout = input_GetAout( pInput );
if( pAout )
{
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;
}
var_AddCallback( pAout, "audio-filter",
onGenericCallback, this );
var_AddCallback( pAout, "equalizer-bands",
onEqBandsChange, this );
var_AddCallback( pAout, "equalizer-preamp",
onEqPreampChange, this );
m_pAout = pAout;
pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
}
else
{
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;
}
// Get the audio filters
pFilters = config_GetPsz( getIntf(), "audio-filter" );
}
// Refresh the equalizer variable
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
pVarEqualizer->set( b_equalizer );
free( pFilters );
break;
}
case INPUT_EVENT_CHAPTER:
{
vlc_value_t chapters_count;
var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
&chapters_count, NULL );
pVarDvdActive->set( chapters_count.i_int > 0 );
break;
}
INPUT_EVENT_DEAD:
INPUT_EVENT_ABORT:
{
var_DelCallback( pInput, "intf-event",
onGenericCallback, this );
var_DelCallback( pInput, "bit-rate",
onGenericCallback, this );
var_DelCallback( pInput, "sample-rate",
onGenericCallback, this );
vlc_object_release( pInput );
getIntf()->p_sys->p_input = NULL;
break;
}
default:
break;
}
}
else
{
// pVarSeekable->set( false );
pVarDvdActive->set( false );
pTime->set( 0, false );
pVarFullscreen->set( false );
pVarHasAudio->set( false );
pVarHasVout->set( false );
pVarStopped->set( true );
pVarPlaying->set( false );
pVarPaused->set( false );
}
}
void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
input_thread_t* pInput = (input_thread_t*) p_obj;
VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
}
void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
input_thread_t* pInput = (input_thread_t*) p_obj;
VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
}
void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
playlist_t* pPlaylist = (playlist_t*) p_obj;
// Refresh the random variable
VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
}
void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
playlist_t* pPlaylist = (playlist_t*) p_obj;
// Refresh the loop variable
VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
}
void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
playlist_t* pPlaylist = (playlist_t*) p_obj;
// Refresh the repeat variable
VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
}
void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
(void)p_obj; (void)newVal;
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
// Refresh sound volume
audio_volume_t volume;
aout_VolumeGet( pPlaylist, &volume );
Volume *pVolume = (Volume*)m_cVarVolume.get();
pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
// Set the mute variable
VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
pVarMute->set( volume == 0 );
}
void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
aout_instance_t* pAout = (aout_instance_t*) p_obj;
char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
// Refresh the equalizer variable
bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
pVarEqualizer->set( b_equalizer );
free( pFilters );
}
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <set> #include <set>
#include <vlc_common.h>
#include <vlc_input.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#include "../vars/equalizer.hpp" #include "../vars/equalizer.hpp"
#include "../vars/playtree.hpp" #include "../vars/playtree.hpp"
...@@ -85,8 +87,17 @@ class VlcProc: public SkinObject ...@@ -85,8 +87,17 @@ class VlcProc: public SkinObject
/// Indicate whether the embedded video output is currently used /// Indicate whether the embedded video output is currently used
bool isVoutUsed() const { return m_pVout != NULL; } bool isVoutUsed() const { return m_pVout != NULL; }
/// Refresh Volume void on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void refreshVolume(); void on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal );
void on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal );
protected: protected:
// Protected because it is a singleton // Protected because it is a singleton
...@@ -147,21 +158,9 @@ class VlcProc: public SkinObject ...@@ -147,21 +158,9 @@ class VlcProc: public SkinObject
/// Define the command that calls manage() /// Define the command that calls manage()
DEFINE_CALLBACK( VlcProc, Manage ); DEFINE_CALLBACK( VlcProc, Manage );
/// Refresh audio variables
void refreshAudio();
/// Refresh playlist variables
void refreshPlaylist();
/// Refresh input variables
void refreshInput();
/// Update the stream name variable /// Update the stream name variable
void updateStreamName(); void updateStreamName();
/// Callback for volume variable
static int onVolumeChanged( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
/// Callback for intf-change variable /// Callback for intf-change variable
static int onIntfChange( vlc_object_t *pObj, const char *pVariable, static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal, vlc_value_t oldVal, vlc_value_t newVal,
...@@ -212,6 +211,12 @@ class VlcProc: public SkinObject ...@@ -212,6 +211,12 @@ class VlcProc: public SkinObject
static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable, static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal, vlc_value_t oldVal, vlc_value_t newVal,
void *pParam ); void *pParam );
/// Generic Callback
static int onGenericCallback( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
void *pParam );
}; };
......
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