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>
9 * Erwan Tulou <erwan10@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include <vlc_common.h>
33 #include <vlc_playlist.h>
36 #include "vlcproc.hpp"
37 #include "os_factory.hpp"
38 #include "os_loop.hpp"
39 #include "os_timer.hpp"
40 #include "var_manager.hpp"
41 #include "vout_manager.hpp"
42 #include "fsc_window.hpp"
44 #include "window_manager.hpp"
45 #include "../commands/async_queue.hpp"
46 #include "../commands/cmd_change_skin.hpp"
47 #include "../commands/cmd_show_window.hpp"
48 #include "../commands/cmd_quit.hpp"
49 #include "../commands/cmd_resize.hpp"
50 #include "../commands/cmd_vars.hpp"
51 #include "../commands/cmd_dialogs.hpp"
52 #include "../commands/cmd_audio.hpp"
53 #include "../commands/cmd_callbacks.hpp"
54 #include "../utils/var_bool.hpp"
55 #include "../utils/var_string.hpp"
60 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
62 if( pIntf->p_sys->p_vlcProc == NULL )
64 pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
67 return pIntf->p_sys->p_vlcProc;
71 void VlcProc::destroy( intf_thread_t *pIntf )
73 delete pIntf->p_sys->p_vlcProc;
74 pIntf->p_sys->p_vlcProc = NULL;
78 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
79 m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ),
80 m_bEqualizer_started( false ), m_cmdManage( this )
82 // Create a timer to poll the status of the vlc
83 OSFactory *pOsFactory = OSFactory::instance( pIntf );
84 m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
85 m_pTimer->start( 100, false );
87 // Create and register VLC variables
88 VarManager *pVarManager = VarManager::instance( getIntf() );
90 #define REGISTER_VAR( var, type, name ) \
91 var = VariablePtr( new type( getIntf() ) ); \
92 pVarManager->registerVar( var, name );
93 REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
94 REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
95 REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
96 REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
97 pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
99 pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
100 pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
102 REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
103 REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
104 REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
106 /* Input variables */
107 pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
108 REGISTER_VAR( m_cVarTime, StreamTime, "time" )
109 REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
110 REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
112 REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" )
113 REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" )
116 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
117 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
120 REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
121 REGISTER_VAR( m_cVarVolume, Volume, "volume" )
122 REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
123 REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
124 REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
127 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
128 pVarManager->registerVar( m_cVarStreamName, "streamName" );
129 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
130 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
131 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
132 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
133 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
134 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
135 m_cVarStreamArt = VariablePtr( new VarString( getIntf() ) );
136 pVarManager->registerVar( m_cVarStreamArt, "streamArt" );
138 // Register the equalizer bands
139 for( int i = 0; i < EqualizerBands::kNbBands; i++)
142 ss << "equalizer.band(" << i << ")";
143 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
147 // The object variable callbacks are called from other VLC threads,
148 // so they must put commands in the queue and NOT do anything else
149 // (X11 calls are not reentrant)
151 #define ADD_CALLBACK( p_object, var ) \
152 var_AddCallback( p_object, var, onGenericCallback, this );
154 ADD_CALLBACK( pIntf->p_sys->p_playlist, "volume" )
155 ADD_CALLBACK( pIntf->p_libvlc, "intf-show" )
157 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
158 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
159 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
160 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
164 // Called when a playlist item is added
165 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
166 onItemAppend, this );
167 // Called when a playlist item is deleted
168 // TODO: properly handle item-deleted
169 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
170 onItemDelete, this );
171 // Called when the current input changes
172 var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
174 // Called when a playlist item changed
175 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
176 onItemChange, this );
178 // Called when we have an interaction dialog to display
179 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
180 var_AddCallback( pIntf, "interaction", onInteraction, this );
182 // initialize variables refering to liblvc and playlist objects
194 vlc_object_release( m_pAout );
199 vlc_object_release( m_pVout );
203 interaction_Unregister( getIntf() );
205 var_DelCallback( getIntf()->p_sys->p_playlist, "volume",
206 onGenericCallback, this );
207 var_DelCallback( getIntf()->p_libvlc, "intf-show",
208 onGenericCallback, this );
210 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
211 onGenericCallback, this );
212 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
213 onGenericCallback, this );
214 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
215 onGenericCallback, this );
216 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
217 onGenericCallback, this );
219 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
220 onItemAppend, this );
221 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
222 onItemDelete, this );
223 var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
225 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
226 onItemChange, this );
227 var_DelCallback( getIntf(), "interaction", onInteraction, this );
230 void VlcProc::manage()
232 // Did the user request to quit vlc ?
233 if( !vlc_object_alive( getIntf() ) )
235 // Get the instance of OSFactory
236 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
238 // Exit the main OS loop
239 pOsFactory->getOSLoop()->exit();
245 void VlcProc::CmdManage::execute()
247 // Just forward to VlcProc
252 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
253 vlc_value_t oldval, vlc_value_t newval, void *pParam )
255 (void)pObj; (void)pVariable; (void)oldval;
256 VlcProc *pThis = (VlcProc*)pParam;
257 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
259 var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
260 var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
261 var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
262 var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
268 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
269 vlc_value_t oldval, vlc_value_t newval,
272 (void)pObj; (void)pVariable; (void)oldval;
273 VlcProc *pThis = (VlcProc*)pParam;
274 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
276 // Create a playtree notify command
277 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
280 // Push the command in the asynchronous command queue
281 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
282 pQueue->push( CmdGenericPtr( pCmdTree ), true );
287 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
288 vlc_value_t oldVal, vlc_value_t newVal,
291 (void)pObj; (void)pVariable; (void)oldVal;
292 VlcProc *pThis = (VlcProc*)pParam;
294 playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
295 CmdPlaytreeAppend *pCmdTree =
296 new CmdPlaytreeAppend( pThis->getIntf(), p_add );
298 // Push the command in the asynchronous command queue
299 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
300 pQueue->push( CmdGenericPtr( pCmdTree ), false );
305 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
306 vlc_value_t oldVal, vlc_value_t newVal,
309 (void)pObj; (void)pVariable; (void)oldVal;
310 VlcProc *pThis = (VlcProc*)pParam;
312 int i_id = newVal.i_int;
313 CmdPlaytreeDelete *pCmdTree =
314 new CmdPlaytreeDelete( pThis->getIntf(), i_id);
316 // Push the command in the asynchronous command queue
317 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
318 pQueue->push( CmdGenericPtr( pCmdTree ), false );
323 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
324 vlc_value_t oldVal, vlc_value_t newVal,
327 (void)pObj; (void)pVariable; (void)oldVal;
328 VlcProc *pThis = (VlcProc*)pParam;
329 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
331 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
332 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
333 pQueue->push( CmdGenericPtr( pCmd ) );
337 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
338 vlc_value_t oldVal, vlc_value_t newVal,
341 (void)pObj; (void)pVariable; (void)oldVal;
342 VlcProc *pThis = (VlcProc*)pParam;
344 // Post a set equalizer bands command
345 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
348 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
349 pQueue->push( CmdGenericPtr( pCmd ) );
355 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
356 vlc_value_t oldVal, vlc_value_t newVal,
359 (void)pObj; (void)pVariable; (void)oldVal;
360 VlcProc *pThis = (VlcProc*)pParam;
361 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
363 // Post a set preamp command
364 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
365 (newVal.f_float + 20.0) / 40.0 );
366 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
367 pQueue->push( CmdGenericPtr( pCmd ) );
373 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
374 vlc_value_t oldVal, vlc_value_t newVal,
378 VlcProc *pThis = (VlcProc*)pParam;
379 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
381 #define ADD_CALLBACK_ENTRY( var, func, remove ) \
383 if( strcmp( pVariable, var ) == 0 ) \
385 string label = var; \
386 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal, \
387 &VlcProc::func, label ); \
389 pQueue->push( CmdGenericPtr( pCmd ), remove ); \
390 return VLC_SUCCESS; \
394 ADD_CALLBACK_ENTRY( "item-current", on_item_current_changed, false )
395 ADD_CALLBACK_ENTRY( "volume", on_volume_changed, true )
397 ADD_CALLBACK_ENTRY( "bit-rate", on_bit_rate_changed, false )
398 ADD_CALLBACK_ENTRY( "sample-rate", on_sample_rate_changed, false )
399 ADD_CALLBACK_ENTRY( "can-record", on_can_record_changed, false )
401 ADD_CALLBACK_ENTRY( "random", on_random_changed, false )
402 ADD_CALLBACK_ENTRY( "loop", on_loop_changed, false )
403 ADD_CALLBACK_ENTRY( "repeat", on_repeat_changed, false )
405 ADD_CALLBACK_ENTRY( "audio-filter", on_audio_filter_changed, false )
407 ADD_CALLBACK_ENTRY( "intf-show", on_intf_show_changed, false )
409 ADD_CALLBACK_ENTRY( "mouse-moved", on_mouse_moved_changed, false )
411 #undef ADD_CALLBACK_ENTRY
413 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
418 int VlcProc::onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
419 vlc_value_t oldVal, vlc_value_t newVal,
423 VlcProc *pThis = (VlcProc*)pParam;
424 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
427 * For intf-event, commands are labeled based on the value of newVal.
429 * For some values (e.g position), only keep the latest command
430 * when there are multiple pending commands (remove=true).
432 * for others, don't discard commands (remove=false)
434 if( strcmp( pVariable, "intf-event" ) == 0 )
438 switch( newVal.i_int )
440 case INPUT_EVENT_STATE:
441 case INPUT_EVENT_POSITION:
443 case INPUT_EVENT_CHAPTER:
444 case INPUT_EVENT_RECORD:
447 case INPUT_EVENT_VOUT:
448 case INPUT_EVENT_AOUT:
449 case INPUT_EVENT_DEAD:
455 label << pVariable << "_" << newVal.i_int;
456 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal,
457 &VlcProc::on_intf_event_changed,
460 pQueue->push( CmdGenericPtr( pCmd ), b_remove );
465 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
470 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
471 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
472 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
473 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
474 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
476 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
479 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
482 char *psz_name = input_item_GetName( p_item );
483 SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
486 // Update local path (if possible) or full uri
487 char *psz_uri = input_item_GetURI( p_item );
488 char *psz_path = make_path( psz_uri );
489 char *psz_save = psz_path ? psz_path : psz_uri;
490 SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
495 char *psz_art = input_item_GetArtURL( p_item );
496 SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
500 getPlaytreeVar().onUpdateCurrent( true );
503 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
505 input_thread_t* pInput = (input_thread_t*) p_obj;
507 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
509 if( !getIntf()->p_sys->p_input )
511 msg_Dbg( getIntf(), "new input %p detected", pInput );
513 getIntf()->p_sys->p_input = pInput;
514 vlc_object_hold( pInput );
517 switch( newVal.i_int )
519 case INPUT_EVENT_STATE:
521 int state = var_GetInteger( pInput, "state" );
522 SET_BOOL( m_cVarStopped, false );
523 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
524 SET_BOOL( m_cVarPaused, state == PAUSE_S );
528 case INPUT_EVENT_POSITION:
530 float pos = var_GetFloat( pInput, "position" );
531 SET_STREAMTIME( m_cVarTime, pos, false );
532 SET_BOOL( m_cVarSeekable, pos != 0.0 );
539 vlc_value_t audio_es;
540 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
542 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
546 case INPUT_EVENT_VOUT:
548 vout_thread_t* pVout = input_GetVout( pInput );
549 SET_BOOL( m_cVarHasVout, pVout != NULL );
550 if( !pVout || pVout == m_pVout )
552 // end of input or vout reuse (nothing to do)
554 vlc_object_release( pVout );
559 // remove previous Vout callbacks
560 var_DelCallback( m_pVout, "mouse-moved",
561 onGenericCallback, this );
562 vlc_object_release( m_pVout );
566 // add new Vout callbackx
567 var_AddCallback( pVout, "mouse-moved",
568 onGenericCallback, this );
573 case INPUT_EVENT_AOUT:
575 aout_instance_t* pAout = input_GetAout( pInput );
577 // end of input or aout reuse (nothing to do)
578 if( !pAout || pAout == m_pAout )
581 vlc_object_release( pAout );
585 // remove previous Aout if any
588 var_DelCallback( m_pAout, "audio-filter",
589 onGenericCallback, this );
590 if( m_bEqualizer_started )
592 var_DelCallback( m_pAout, "equalizer-bands",
593 onEqBandsChange, this );
594 var_DelCallback( m_pAout, "equalizer-preamp",
595 onEqPreampChange, this );
597 vlc_object_release( m_pAout );
599 m_bEqualizer_started = false;
602 // New Aout (addCallbacks)
603 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
605 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
606 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
608 SET_BOOL( m_cVarEqualizer, b_equalizer );
611 var_AddCallback( pAout, "equalizer-bands",
612 onEqBandsChange, this );
613 var_AddCallback( pAout, "equalizer-preamp",
614 onEqPreampChange, this );
615 m_bEqualizer_started = true;
621 case INPUT_EVENT_CHAPTER:
623 vlc_value_t chapters_count;
624 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
625 &chapters_count, NULL );
626 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
630 case INPUT_EVENT_RECORD:
631 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
634 case INPUT_EVENT_DEAD:
635 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
637 var_DelCallback( pInput, "intf-event", onGenericCallback2, this );
638 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
639 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
640 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
641 vlc_object_release( pInput );
642 getIntf()->p_sys->p_input = NULL;
651 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
654 input_thread_t* pInput = (input_thread_t*) p_obj;
656 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
658 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
659 SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
662 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
665 input_thread_t* pInput = (input_thread_t*) p_obj;
667 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
669 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
670 SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
673 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
676 input_thread_t* pInput = (input_thread_t*) p_obj;
678 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
680 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
683 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
686 playlist_t* pPlaylist = (playlist_t*) p_obj;
688 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
691 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
694 playlist_t* pPlaylist = (playlist_t*) p_obj;
696 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
699 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
702 playlist_t* pPlaylist = (playlist_t*) p_obj;
704 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
707 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
709 (void)p_obj; (void)newVal;
710 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
712 audio_volume_t volume = aout_VolumeGet( pPlaylist );
713 SET_VOLUME( m_cVarVolume, volume, false );
714 SET_BOOL( m_cVarMute, volume == 0 );
717 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
720 aout_instance_t* pAout = (aout_instance_t*) p_obj;
722 char *pFilters = newVal.psz_string;
724 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
725 SET_BOOL( m_cVarEqualizer, b_equalizer );
726 if( b_equalizer && !m_bEqualizer_started )
728 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
729 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
730 m_bEqualizer_started = true;
734 void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
736 (void)p_obj; (void)newVal;
737 bool b_fullscreen = getFullscreenVar().get();
743 // Create a raise all command
744 CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
745 getIntf()->p_sys->p_theme->getWindowManager() );
747 // Push the command in the asynchronous command queue
748 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
749 pQueue->push( CmdGenericPtr( pCmd ) );
754 VoutManager* pVoutManager = VoutManager::instance( getIntf() );
755 FscWindow *pWin = pVoutManager->getFscWindow();
758 bool b_visible = pWin->getVisibleVar().get();
759 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
763 CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
764 getIntf()->p_sys->p_theme->getWindowManager(),
766 pQueue->push( CmdGenericPtr( pCmd ) );
770 CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
771 getIntf()->p_sys->p_theme->getWindowManager(),
773 pQueue->push( CmdGenericPtr( pCmd ) );
779 void VlcProc::on_mouse_moved_changed( vlc_object_t* p_obj, vlc_value_t newVal )
781 (void)p_obj; (void)newVal;
782 FscWindow* pFscWindow = VoutManager::instance( getIntf() )->getFscWindow();
784 pFscWindow->onMouseMoved();
787 void VlcProc::reset_input()
789 SET_BOOL( m_cVarSeekable, false );
790 SET_BOOL( m_cVarRecordable, false );
791 SET_BOOL( m_cVarRecording, false );
792 SET_BOOL( m_cVarDvdActive, false );
793 SET_BOOL( m_cVarHasAudio, false );
794 SET_BOOL( m_cVarHasVout, false );
795 SET_BOOL( m_cVarStopped, true );
796 SET_BOOL( m_cVarPlaying, false );
797 SET_BOOL( m_cVarPaused, false );
799 SET_STREAMTIME( m_cVarTime, 0, false );
800 SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
801 SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
802 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
803 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
805 getPlaytreeVar().onUpdateCurrent( false );
808 void VlcProc::init_variables()
810 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
812 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
813 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
814 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
816 audio_volume_t volume = aout_VolumeGet( pPlaylist );
817 SET_VOLUME( m_cVarVolume, volume, false );
818 SET_BOOL( m_cVarMute, volume == 0 );
823 void VlcProc::update_equalizer()
828 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
830 pFilters = var_InheritString( getIntf(), "audio-filter" );
832 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
835 SET_BOOL( m_cVarEqualizer, b_equalizer );
838 void VlcProc::setFullscreenVar( bool b_fullscreen )
840 SET_BOOL( m_cVarFullscreen, b_fullscreen );
844 #undef SET_STREAMTIME