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;
77 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
78 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
79 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
80 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
81 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->setVolume(v,b)
83 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
84 m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ),
85 m_bEqualizer_started( 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_cVarSpeed = VariablePtr( new VarText( getIntf(), false ) );
128 pVarManager->registerVar( m_cVarSpeed, "speed" );
129 SET_TEXT( m_cVarSpeed, UString( getIntf(), "1") );
130 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
131 pVarManager->registerVar( m_cVarStreamName, "streamName" );
132 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
133 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
134 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
135 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
136 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
137 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
138 m_cVarStreamArt = VariablePtr( new VarString( getIntf() ) );
139 pVarManager->registerVar( m_cVarStreamArt, "streamArt" );
141 // Register the equalizer bands
142 for( int i = 0; i < EqualizerBands::kNbBands; i++)
145 ss << "equalizer.band(" << i << ")";
146 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
150 // The object variable callbacks are called from other VLC threads,
151 // so they must put commands in the queue and NOT do anything else
152 // (X11 calls are not reentrant)
154 #define ADD_CALLBACK( p_object, var ) \
155 var_AddCallback( p_object, var, onGenericCallback, this );
157 ADD_CALLBACK( pIntf->p_sys->p_playlist, "volume" )
158 ADD_CALLBACK( pIntf->p_libvlc, "intf-toggle-fscontrol" )
160 ADD_CALLBACK( pIntf->p_sys->p_playlist, "activity" )
161 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
162 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
163 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
167 // Called when a playlist item is added
168 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
169 onItemAppend, this );
170 // Called when a playlist item is deleted
171 // TODO: properly handle item-deleted
172 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
173 onItemDelete, this );
174 // Called when the current input changes
175 var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
177 // Called when a playlist item changed
178 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
179 onItemChange, this );
181 // Called when we have an interaction dialog to display
182 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
183 var_AddCallback( pIntf, "interaction", onInteraction, this );
185 // initialize variables refering to liblvc and playlist objects
194 vlc_object_release( m_pAout );
199 vlc_object_release( m_pVout );
203 var_DelCallback( getIntf()->p_sys->p_playlist, "volume",
204 onGenericCallback, this );
205 var_DelCallback( getIntf()->p_libvlc, "intf-toggle-fscontrol",
206 onGenericCallback, this );
208 var_DelCallback( getIntf()->p_sys->p_playlist, "activity",
209 onGenericCallback, this );
210 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
211 onGenericCallback, this );
212 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
213 onGenericCallback, this );
214 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
215 onGenericCallback, 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_sys->p_playlist, "input-current",
223 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
224 onItemChange, this );
225 var_DelCallback( getIntf(), "interaction", onInteraction, this );
228 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
229 vlc_value_t oldval, vlc_value_t newval, void *pParam )
231 (void)pObj; (void)pVariable; (void)oldval;
232 VlcProc *pThis = (VlcProc*)pParam;
233 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
235 var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
236 var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
237 var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
238 var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
244 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
245 vlc_value_t oldval, vlc_value_t newval,
248 (void)pObj; (void)pVariable; (void)oldval;
249 VlcProc *pThis = (VlcProc*)pParam;
250 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
252 // Create a playtree notify command
253 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
256 // Push the command in the asynchronous command queue
257 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
258 pQueue->push( CmdGenericPtr( pCmdTree ), true );
263 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
264 vlc_value_t oldVal, vlc_value_t newVal,
267 (void)pObj; (void)pVariable; (void)oldVal;
268 VlcProc *pThis = (VlcProc*)pParam;
270 playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
271 CmdPlaytreeAppend *pCmdTree =
272 new CmdPlaytreeAppend( pThis->getIntf(), p_add );
274 // Push the command in the asynchronous command queue
275 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
276 pQueue->push( CmdGenericPtr( pCmdTree ), false );
281 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
282 vlc_value_t oldVal, vlc_value_t newVal,
285 (void)pObj; (void)pVariable; (void)oldVal;
286 VlcProc *pThis = (VlcProc*)pParam;
288 int i_id = newVal.i_int;
289 CmdPlaytreeDelete *pCmdTree =
290 new CmdPlaytreeDelete( pThis->getIntf(), i_id);
292 // Push the command in the asynchronous command queue
293 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
294 pQueue->push( CmdGenericPtr( pCmdTree ), false );
299 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
300 vlc_value_t oldVal, vlc_value_t newVal,
303 (void)pObj; (void)pVariable; (void)oldVal;
304 VlcProc *pThis = (VlcProc*)pParam;
305 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
307 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
308 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
309 pQueue->push( CmdGenericPtr( pCmd ) );
313 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
314 vlc_value_t oldVal, vlc_value_t newVal,
317 (void)pObj; (void)pVariable; (void)oldVal;
318 VlcProc *pThis = (VlcProc*)pParam;
320 // Post a set equalizer bands command
321 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
324 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
325 pQueue->push( CmdGenericPtr( pCmd ) );
331 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
332 vlc_value_t oldVal, vlc_value_t newVal,
335 (void)pObj; (void)pVariable; (void)oldVal;
336 VlcProc *pThis = (VlcProc*)pParam;
337 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
339 // Post a set preamp command
340 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
341 (newVal.f_float + 20.0) / 40.0 );
342 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
343 pQueue->push( CmdGenericPtr( pCmd ) );
349 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
350 vlc_value_t oldVal, vlc_value_t newVal,
354 VlcProc *pThis = (VlcProc*)pParam;
355 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
357 #define ADD_CALLBACK_ENTRY( var, func, remove ) \
359 if( strcmp( pVariable, var ) == 0 ) \
361 string label = var; \
362 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal, \
363 &VlcProc::func, label ); \
365 pQueue->push( CmdGenericPtr( pCmd ), remove ); \
366 return VLC_SUCCESS; \
370 ADD_CALLBACK_ENTRY( "activity", on_item_current_changed, false )
371 ADD_CALLBACK_ENTRY( "volume", on_volume_changed, true )
373 ADD_CALLBACK_ENTRY( "bit-rate", on_bit_rate_changed, false )
374 ADD_CALLBACK_ENTRY( "sample-rate", on_sample_rate_changed, false )
375 ADD_CALLBACK_ENTRY( "can-record", on_can_record_changed, false )
377 ADD_CALLBACK_ENTRY( "random", on_random_changed, false )
378 ADD_CALLBACK_ENTRY( "loop", on_loop_changed, false )
379 ADD_CALLBACK_ENTRY( "repeat", on_repeat_changed, false )
381 ADD_CALLBACK_ENTRY( "audio-filter", on_audio_filter_changed, false )
383 ADD_CALLBACK_ENTRY( "intf-toggle-fscontrol", on_intf_show_changed, false )
385 ADD_CALLBACK_ENTRY( "mouse-moved", on_mouse_moved_changed, false )
387 #undef ADD_CALLBACK_ENTRY
389 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
394 int VlcProc::onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
395 vlc_value_t oldVal, vlc_value_t newVal,
399 VlcProc *pThis = (VlcProc*)pParam;
400 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
403 * For intf-event, commands are labeled based on the value of newVal.
405 * For some values (e.g position), only keep the latest command
406 * when there are multiple pending commands (remove=true).
408 * for others, don't discard commands (remove=false)
410 if( strcmp( pVariable, "intf-event" ) == 0 )
414 switch( newVal.i_int )
416 case INPUT_EVENT_STATE:
417 case INPUT_EVENT_POSITION:
418 case INPUT_EVENT_RATE:
420 case INPUT_EVENT_CHAPTER:
421 case INPUT_EVENT_RECORD:
424 case INPUT_EVENT_VOUT:
425 case INPUT_EVENT_AOUT:
426 case INPUT_EVENT_DEAD:
432 label << pVariable << "_" << newVal.i_int;
433 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal,
434 &VlcProc::on_intf_event_changed,
437 pQueue->push( CmdGenericPtr( pCmd ), b_remove );
442 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
447 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
450 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
453 char *psz_name = input_item_GetName( p_item );
454 SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
457 // Update local path (if possible) or full uri
458 char *psz_uri = input_item_GetURI( p_item );
459 char *psz_path = make_path( psz_uri );
460 char *psz_save = psz_path ? psz_path : psz_uri;
461 SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
466 char *psz_art = input_item_GetArtURL( p_item );
467 SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
471 getPlaytreeVar().onUpdateCurrent( true );
474 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
476 input_thread_t* pInput = (input_thread_t*) p_obj;
478 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
480 if( !getIntf()->p_sys->p_input )
482 msg_Dbg( getIntf(), "new input %p detected", pInput );
484 getIntf()->p_sys->p_input = pInput;
485 vlc_object_hold( pInput );
488 switch( newVal.i_int )
490 case INPUT_EVENT_STATE:
492 int state = var_GetInteger( pInput, "state" );
493 SET_BOOL( m_cVarStopped, false );
494 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
495 SET_BOOL( m_cVarPaused, state == PAUSE_S );
499 case INPUT_EVENT_POSITION:
501 float pos = var_GetFloat( pInput, "position" );
502 SET_STREAMTIME( m_cVarTime, pos, false );
503 SET_BOOL( m_cVarSeekable, pos != 0.0 );
507 case INPUT_EVENT_RATE:
509 float rate = var_GetFloat( pInput, "rate" );
511 if( asprintf( &buffer, "%.3g", rate ) != -1 )
513 SET_TEXT( m_cVarSpeed, UString( getIntf(), buffer ) );
522 vlc_value_t audio_es;
523 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
525 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
529 case INPUT_EVENT_VOUT:
531 vout_thread_t* pVout = input_GetVout( pInput );
532 SET_BOOL( m_cVarHasVout, pVout != NULL );
533 if( !pVout || pVout == m_pVout )
535 // end of input or vout reuse (nothing to do)
537 vlc_object_release( pVout );
542 // remove previous Vout callbacks
543 var_DelCallback( m_pVout, "mouse-moved",
544 onGenericCallback, this );
545 vlc_object_release( m_pVout );
549 // add new Vout callbackx
550 var_AddCallback( pVout, "mouse-moved",
551 onGenericCallback, this );
556 case INPUT_EVENT_AOUT:
558 audio_output_t* pAout = input_GetAout( pInput );
560 // end of input or aout reuse (nothing to do)
561 if( !pAout || pAout == m_pAout )
564 vlc_object_release( pAout );
568 // remove previous Aout if any
571 var_DelCallback( m_pAout, "audio-filter",
572 onGenericCallback, this );
573 if( m_bEqualizer_started )
575 var_DelCallback( m_pAout, "equalizer-bands",
576 onEqBandsChange, this );
577 var_DelCallback( m_pAout, "equalizer-preamp",
578 onEqPreampChange, this );
580 vlc_object_release( m_pAout );
582 m_bEqualizer_started = false;
585 // New Aout (addCallbacks)
586 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
588 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
589 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
591 SET_BOOL( m_cVarEqualizer, b_equalizer );
594 var_AddCallback( pAout, "equalizer-bands",
595 onEqBandsChange, this );
596 var_AddCallback( pAout, "equalizer-preamp",
597 onEqPreampChange, this );
598 m_bEqualizer_started = true;
604 case INPUT_EVENT_CHAPTER:
606 vlc_value_t chapters_count;
607 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
608 &chapters_count, NULL );
609 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
613 case INPUT_EVENT_RECORD:
614 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
617 case INPUT_EVENT_DEAD:
618 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
620 var_DelCallback( pInput, "intf-event", onGenericCallback2, this );
621 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
622 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
623 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
624 vlc_object_release( pInput );
625 getIntf()->p_sys->p_input = NULL;
634 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
637 input_thread_t* pInput = (input_thread_t*) p_obj;
639 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
641 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
642 SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
645 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
648 input_thread_t* pInput = (input_thread_t*) p_obj;
650 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
652 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
653 SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
656 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
659 input_thread_t* pInput = (input_thread_t*) p_obj;
661 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
663 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
666 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
669 playlist_t* pPlaylist = (playlist_t*) p_obj;
671 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
674 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
677 playlist_t* pPlaylist = (playlist_t*) p_obj;
679 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
682 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
685 playlist_t* pPlaylist = (playlist_t*) p_obj;
687 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
690 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
692 (void)p_obj; (void)newVal;
693 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
695 SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
696 bool b_is_muted = playlist_MuteGet( pPlaylist ) > 0;
697 SET_BOOL( m_cVarMute, b_is_muted );
700 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
703 audio_output_t* pAout = (audio_output_t*) p_obj;
705 char *pFilters = newVal.psz_string;
707 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
708 SET_BOOL( m_cVarEqualizer, b_equalizer );
709 if( b_equalizer && !m_bEqualizer_started )
711 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
712 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
713 m_bEqualizer_started = true;
717 void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
719 (void)p_obj; (void)newVal;
720 bool b_fullscreen = getFullscreenVar().get();
726 // Create a raise all command
727 CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
728 getIntf()->p_sys->p_theme->getWindowManager() );
730 // Push the command in the asynchronous command queue
731 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
732 pQueue->push( CmdGenericPtr( pCmd ) );
737 VoutManager* pVoutManager = VoutManager::instance( getIntf() );
738 FscWindow *pWin = pVoutManager->getFscWindow();
741 bool b_visible = pWin->getVisibleVar().get();
742 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
746 CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
747 getIntf()->p_sys->p_theme->getWindowManager(),
749 pQueue->push( CmdGenericPtr( pCmd ) );
753 CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
754 getIntf()->p_sys->p_theme->getWindowManager(),
756 pQueue->push( CmdGenericPtr( pCmd ) );
762 void VlcProc::on_mouse_moved_changed( vlc_object_t* p_obj, vlc_value_t newVal )
764 (void)p_obj; (void)newVal;
765 FscWindow* pFscWindow = VoutManager::instance( getIntf() )->getFscWindow();
767 pFscWindow->onMouseMoved();
770 void VlcProc::reset_input()
772 SET_BOOL( m_cVarSeekable, false );
773 SET_BOOL( m_cVarRecordable, false );
774 SET_BOOL( m_cVarRecording, false );
775 SET_BOOL( m_cVarDvdActive, false );
776 SET_BOOL( m_cVarHasAudio, false );
777 SET_BOOL( m_cVarHasVout, false );
778 SET_BOOL( m_cVarStopped, true );
779 SET_BOOL( m_cVarPlaying, false );
780 SET_BOOL( m_cVarPaused, false );
782 SET_STREAMTIME( m_cVarTime, 0, false );
783 SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
784 SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
785 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
786 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
788 getPlaytreeVar().onUpdateCurrent( false );
791 void VlcProc::init_variables()
793 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
795 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
796 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
797 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
799 SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
800 bool b_is_muted = playlist_MuteGet( pPlaylist ) > 0;
801 SET_BOOL( m_cVarMute, b_is_muted );
806 void VlcProc::update_equalizer()
811 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
813 pFilters = var_InheritString( getIntf(), "audio-filter" );
815 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
818 SET_BOOL( m_cVarEqualizer, b_equalizer );
821 void VlcProc::setFullscreenVar( bool b_fullscreen )
823 SET_BOOL( m_cVarFullscreen, b_fullscreen );
827 #undef SET_STREAMTIME