1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003-2009 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
32 #include <vlc_playlist.h>
34 #include "vlcproc.hpp"
35 #include "os_factory.hpp"
36 #include "os_loop.hpp"
37 #include "os_timer.hpp"
38 #include "var_manager.hpp"
39 #include "vout_manager.hpp"
41 #include "window_manager.hpp"
42 #include "../commands/async_queue.hpp"
43 #include "../commands/cmd_change_skin.hpp"
44 #include "../commands/cmd_show_window.hpp"
45 #include "../commands/cmd_quit.hpp"
46 #include "../commands/cmd_resize.hpp"
47 #include "../commands/cmd_vars.hpp"
48 #include "../commands/cmd_dialogs.hpp"
49 #include "../commands/cmd_update_item.hpp"
50 #include "../commands/cmd_audio.hpp"
51 #include "../commands/cmd_callbacks.hpp"
52 #include "../utils/var_bool.hpp"
56 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
58 if( pIntf->p_sys->p_vlcProc == NULL )
60 pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
63 return pIntf->p_sys->p_vlcProc;
67 void VlcProc::destroy( intf_thread_t *pIntf )
69 delete pIntf->p_sys->p_vlcProc;
70 pIntf->p_sys->p_vlcProc = NULL;
74 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
75 m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
76 m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
78 // Create a timer to poll the status of the vlc
79 OSFactory *pOsFactory = OSFactory::instance( pIntf );
80 m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
81 m_pTimer->start( 100, false );
83 // Create and register VLC variables
84 VarManager *pVarManager = VarManager::instance( getIntf() );
86 #define REGISTER_VAR( var, type, name ) \
87 var = VariablePtr( new type( getIntf() ) ); \
88 pVarManager->registerVar( var, name );
89 REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
90 REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
91 REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
92 REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
93 pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
95 pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
96 pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
98 REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
99 REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
100 REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
102 /* Input variables */
103 pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
104 REGISTER_VAR( m_cVarTime, StreamTime, "time" )
105 REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
106 REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
109 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
110 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
113 REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
114 REGISTER_VAR( m_cVarVolume, Volume, "volume" )
115 REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
116 REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
117 REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
120 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
121 pVarManager->registerVar( m_cVarStreamName, "streamName" );
122 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
123 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
124 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
125 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
126 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
127 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
129 // Register the equalizer bands
130 for( int i = 0; i < EqualizerBands::kNbBands; i++)
133 ss << "equalizer.band(" << i << ")";
134 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
138 // The object variable callbacks are called from other VLC threads,
139 // so they must put commands in the queue and NOT do anything else
140 // (X11 calls are not reentrant)
142 // Called when volume sound changes
143 #define ADD_CALLBACK( p_object, var ) \
144 var_AddCallback( p_object, var, onGenericCallback, this );
146 ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
148 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
149 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
150 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
151 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
155 // Called when the playlist changes
156 var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
157 onIntfChange, this );
158 // Called when a playlist item is added
159 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
160 onItemAppend, this );
161 // Called when a playlist item is deleted
162 // TODO: properly handle item-deleted
163 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
164 onItemDelete, this );
165 // Called when the "interface shower" wants us to show the skin
166 var_AddCallback( pIntf->p_libvlc, "intf-show",
168 // Called when the current played item changes
169 var_AddCallback( pIntf->p_sys->p_playlist, "item-current",
170 onPlaylistChange, this );
171 // Called when a playlist item changed
172 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
173 onItemChange, this );
174 // Called when our skins2 demux wants us to load a new skin
175 var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
177 // Called when we have an interaction dialog to display
178 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
179 var_AddCallback( pIntf, "interaction", onInteraction, this );
180 interaction_Register( pIntf );
182 getIntf()->p_sys->p_input = NULL;
193 vlc_object_release( m_pAout );
198 vlc_object_release( m_pVout );
202 input_thread_t* pInput = getIntf()->p_sys->p_input;
205 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
206 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
207 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
209 vlc_object_release( pInput );
210 getIntf()->p_sys->p_input = NULL;
213 interaction_Unregister( getIntf() );
215 var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
216 onIntfChange, this );
217 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
218 onItemAppend, this );
219 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
220 onItemDelete, this );
221 var_DelCallback( getIntf()->p_libvlc, "intf-show",
223 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
224 onGenericCallback, this );
225 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
226 onPlaylistChange, this );
227 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
228 onItemChange, this );
229 var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
230 var_DelCallback( getIntf(), "interaction", onInteraction, this );
233 void VlcProc::manage()
235 // Did the user request to quit vlc ?
236 if( !vlc_object_alive( getIntf() ) )
238 // Get the instance of OSFactory
239 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
241 // Exit the main OS loop
242 pOsFactory->getOSLoop()->exit();
248 void VlcProc::CmdManage::execute()
250 // Just forward to VlcProc
255 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
256 vlc_value_t oldVal, vlc_value_t newVal,
259 VlcProc *pThis = (VlcProc*)pParam;
261 // Update the stream variable
262 pThis->updateStreamName();
264 // Create a playtree notify command (for new style playtree)
265 CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
267 // Push the command in the asynchronous command queue
268 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
269 pQueue->push( CmdGenericPtr( pCmdTree ) );
275 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
276 vlc_value_t oldVal, vlc_value_t newVal,
281 VlcProc *pThis = (VlcProc*)pParam;
283 // Create a raise all command
284 CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
285 pThis->getIntf()->p_sys->p_theme->getWindowManager() );
287 // Push the command in the asynchronous command queue
288 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
289 pQueue->push( CmdGenericPtr( pCmd ) );
296 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
297 vlc_value_t oldval, vlc_value_t newval,
300 VlcProc *pThis = (VlcProc*)pParam;
301 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
303 // Update the stream variable
304 pThis->updateStreamName();
306 // Create a playtree notify command
307 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
310 // Push the command in the asynchronous command queue
311 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
312 pQueue->push( CmdGenericPtr( pCmdTree ), true );
317 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
318 vlc_value_t oldVal, vlc_value_t newVal,
321 VlcProc *pThis = (VlcProc*)pParam;
323 playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
326 memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
328 CmdGenericPtr ptrTree;
329 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
331 ptrTree = CmdGenericPtr( pCmdTree );
333 // Push the command in the asynchronous command queue
334 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
335 pQueue->push( ptrTree , false );
340 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
341 vlc_value_t oldVal, vlc_value_t newVal,
344 VlcProc *pThis = (VlcProc*)pParam;
346 int i_id = newVal.i_int;
348 CmdGenericPtr ptrTree;
349 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
351 ptrTree = CmdGenericPtr( pCmdTree );
353 // Push the command in the asynchronous command queue
354 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
355 pQueue->push( ptrTree , false );
361 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
362 vlc_value_t oldval, vlc_value_t newval,
365 VlcProc *pThis = (VlcProc*)pParam;
366 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
368 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
370 // Update the stream variable
371 pThis->updateStreamName();
373 // Create two playtree notify commands: one for old item, one for new
374 #if 0 /* FIXME: Heck, no! You cannot do that.
375 There is no warranty that the old item is still valid. */
376 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
378 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
380 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), p_item->i_id );
381 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
387 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
388 vlc_value_t oldVal, vlc_value_t newVal,
391 VlcProc *pThis = (VlcProc*)pParam;
393 // Create a playlist notify command
394 CmdChangeSkin *pCmd =
395 new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
397 // Push the command in the asynchronous command queue
398 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
399 pQueue->push( CmdGenericPtr( pCmd ) );
404 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
405 vlc_value_t oldVal, vlc_value_t newVal,
408 VlcProc *pThis = (VlcProc*)pParam;
409 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
411 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
412 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
413 pQueue->push( CmdGenericPtr( pCmd ) );
418 void VlcProc::updateStreamName()
420 // Create a update item command
421 CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
423 // Push the command in the asynchronous command queue
424 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
425 pQueue->push( CmdGenericPtr( pCmdItem ) );
428 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
429 vlc_value_t oldVal, vlc_value_t newVal,
432 VlcProc *pThis = (VlcProc*)pParam;
434 // Post a set equalizer bands command
435 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
438 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
439 pQueue->push( CmdGenericPtr( pCmd ) );
445 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
446 vlc_value_t oldVal, vlc_value_t newVal,
449 VlcProc *pThis = (VlcProc*)pParam;
450 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
452 // Post a set preamp command
453 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
454 (newVal.f_float + 20.0) / 40.0 );
455 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
456 pQueue->push( CmdGenericPtr( pCmd ) );
462 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
463 vlc_value_t oldVal, vlc_value_t newVal,
466 VlcProc *pThis = (VlcProc*)pParam;
467 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
469 CmdGeneric *pCmd = NULL;
471 #define ADD_CALLBACK_ENTRY( var, label ) \
473 if( strcmp( pVariable, var ) == 0 ) \
474 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
477 ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
478 ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
480 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
481 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
482 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
484 ADD_CALLBACK_ENTRY( "random", random_changed )
485 ADD_CALLBACK_ENTRY( "loop", loop_changed )
486 ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
488 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
490 #undef ADD_CALLBACK_ENTRY
493 pQueue->push( CmdGenericPtr( pCmd ), false );
495 msg_Err( pObj, "no Callback entry provided for %s", pVariable );
500 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
502 input_thread_t* pInput = getIntf()->p_sys->p_input;
505 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
506 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
507 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
508 vlc_object_release( pInput );
509 pInput = getIntf()->p_sys->p_input = NULL;
512 playlist_t * pPlaylist = getIntf()->p_sys->p_playlist;
513 pInput = playlist_CurrentInput( pPlaylist );
517 var_AddCallback( pInput, "intf-event", onGenericCallback, this );
518 var_AddCallback( pInput, "bit-rate", onGenericCallback, this );
519 var_AddCallback( pInput, "sample-rate", onGenericCallback, this );
520 getIntf()->p_sys->p_input = pInput;
523 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
525 input_thread_t* pInput = (input_thread_t*) p_obj;
527 StreamTime *pTime = (StreamTime*)m_cVarTime.get();
528 VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
529 VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
530 VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
531 VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
532 VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
533 VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
534 VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
535 VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
536 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
538 if( vlc_object_alive( pInput ) )
540 switch( newVal.i_int )
542 case INPUT_EVENT_STATE:
544 int state = var_GetInteger( pInput, "state" );
545 pVarStopped->set( false );
546 pVarPlaying->set( state != PAUSE_S );
547 pVarPaused->set( state == PAUSE_S );
551 case INPUT_EVENT_POSITION:
553 float pos = var_GetFloat( pInput, "position" );
554 pTime->set( pos, false );
555 pVarSeekable->set( pos != 0.0 );
562 vlc_value_t audio_es;
563 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
565 pVarHasAudio->set( audio_es.i_int > 0 );
569 case INPUT_EVENT_VOUT:
571 vout_thread_t* pVout = input_GetVout( pInput );
572 pVarHasVout->set( pVout != NULL );
575 pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
576 vlc_object_release( pVout );
581 case INPUT_EVENT_AOUT:
584 aout_instance_t* pAout = input_GetAout( pInput );
589 var_DelCallback( m_pAout, "audio-filter",
590 onGenericCallback, this );
591 var_DelCallback( m_pAout, "equalizer-bands",
592 onEqBandsChange, this );
593 var_DelCallback( m_pAout, "equalizer-preamp",
594 onEqPreampChange, this );
595 vlc_object_release( m_pAout );
599 var_AddCallback( pAout, "audio-filter",
600 onGenericCallback, this );
601 var_AddCallback( pAout, "equalizer-bands",
602 onEqBandsChange, this );
603 var_AddCallback( pAout, "equalizer-preamp",
604 onEqPreampChange, this );
607 pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
613 var_DelCallback( m_pAout, "audio-filter",
614 onGenericCallback, this );
615 var_DelCallback( m_pAout, "equalizer-bands",
616 onEqBandsChange, this );
617 var_DelCallback( m_pAout, "equalizer-preamp",
618 onEqPreampChange, this );
619 vlc_object_release( m_pAout );
622 // Get the audio filters
623 pFilters = config_GetPsz( getIntf(), "audio-filter" );
625 // Refresh the equalizer variable
626 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
627 pVarEqualizer->set( b_equalizer );
632 case INPUT_EVENT_CHAPTER:
634 vlc_value_t chapters_count;
635 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
636 &chapters_count, NULL );
637 pVarDvdActive->set( chapters_count.i_int > 0 );
644 var_DelCallback( pInput, "intf-event",
645 onGenericCallback, this );
646 var_DelCallback( pInput, "bit-rate",
647 onGenericCallback, this );
648 var_DelCallback( pInput, "sample-rate",
649 onGenericCallback, this );
650 vlc_object_release( pInput );
651 getIntf()->p_sys->p_input = NULL;
661 // pVarSeekable->set( false );
662 pVarDvdActive->set( false );
663 pTime->set( 0, false );
664 pVarFullscreen->set( false );
665 pVarHasAudio->set( false );
666 pVarHasVout->set( false );
667 pVarStopped->set( true );
668 pVarPlaying->set( false );
669 pVarPaused->set( false );
673 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
675 input_thread_t* pInput = (input_thread_t*) p_obj;
677 VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
679 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
680 pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
683 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
685 input_thread_t* pInput = (input_thread_t*) p_obj;
687 VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
689 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
690 pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
693 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
695 playlist_t* pPlaylist = (playlist_t*) p_obj;
697 // Refresh the random variable
698 VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
699 pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
702 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
704 playlist_t* pPlaylist = (playlist_t*) p_obj;
706 // Refresh the loop variable
707 VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
708 pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
711 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
713 playlist_t* pPlaylist = (playlist_t*) p_obj;
715 // Refresh the repeat variable
716 VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
717 pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
721 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
723 (void)p_obj; (void)newVal;
724 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
726 // Refresh sound volume
727 audio_volume_t volume;
728 aout_VolumeGet( pPlaylist, &volume );
729 Volume *pVolume = (Volume*)m_cVarVolume.get();
730 pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
732 // Set the mute variable
733 VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
734 pVarMute->set( volume == 0 );
737 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
739 aout_instance_t* pAout = (aout_instance_t*) p_obj;
741 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
743 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
745 // Refresh the equalizer variable
746 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
747 pVarEqualizer->set( b_equalizer );