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_sys->p_playlist, "mute" )
159 ADD_CALLBACK( pIntf->p_libvlc, "intf-toggle-fscontrol" )
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_sys->p_playlist, "mute",
206 onGenericCallback, this );
207 var_DelCallback( getIntf()->p_libvlc, "intf-toggle-fscontrol",
208 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 CmdItemUpdate *pCmdTree = new CmdItemUpdate( 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( "volume", on_volume_changed, true )
371 ADD_CALLBACK_ENTRY( "mute", on_mute_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_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
449 input_thread_t* pInput = (input_thread_t*) p_obj;
451 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
453 if( !getIntf()->p_sys->p_input )
455 msg_Dbg( getIntf(), "new input %p detected", pInput );
457 getIntf()->p_sys->p_input = pInput;
458 vlc_object_hold( pInput );
460 // update global variables pertaining to this input
461 update_current_input();
463 // ensure the playtree is also updated
464 // (highlights the new item to be played back)
465 getPlaytreeVar().onUpdateCurrent( true );
468 switch( newVal.i_int )
470 case INPUT_EVENT_STATE:
472 int state = var_GetInteger( pInput, "state" );
473 SET_BOOL( m_cVarStopped, false );
474 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
475 SET_BOOL( m_cVarPaused, state == PAUSE_S );
479 case INPUT_EVENT_POSITION:
481 float pos = var_GetFloat( pInput, "position" );
482 SET_STREAMTIME( m_cVarTime, pos, false );
483 SET_BOOL( m_cVarSeekable, pos != 0.0 );
487 case INPUT_EVENT_RATE:
489 float rate = var_GetFloat( pInput, "rate" );
491 if( asprintf( &buffer, "%.3g", rate ) != -1 )
493 SET_TEXT( m_cVarSpeed, UString( getIntf(), buffer ) );
502 vlc_value_t audio_es;
503 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
505 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
509 case INPUT_EVENT_VOUT:
511 vout_thread_t* pVout = input_GetVout( pInput );
512 SET_BOOL( m_cVarHasVout, pVout != NULL );
513 if( !pVout || pVout == m_pVout )
515 // end of input or vout reuse (nothing to do)
517 vlc_object_release( pVout );
522 // remove previous Vout callbacks
523 var_DelCallback( m_pVout, "mouse-moved",
524 onGenericCallback, this );
525 vlc_object_release( m_pVout );
529 // add new Vout callbackx
530 var_AddCallback( pVout, "mouse-moved",
531 onGenericCallback, this );
536 case INPUT_EVENT_AOUT:
538 audio_output_t* pAout = input_GetAout( pInput );
540 // end of input or aout reuse (nothing to do)
541 if( !pAout || pAout == m_pAout )
544 vlc_object_release( pAout );
548 // remove previous Aout if any
551 var_DelCallback( m_pAout, "audio-filter",
552 onGenericCallback, this );
553 if( m_bEqualizer_started )
555 var_DelCallback( m_pAout, "equalizer-bands",
556 onEqBandsChange, this );
557 var_DelCallback( m_pAout, "equalizer-preamp",
558 onEqPreampChange, this );
560 vlc_object_release( m_pAout );
562 m_bEqualizer_started = false;
565 // New Aout (addCallbacks)
566 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
568 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
569 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
571 SET_BOOL( m_cVarEqualizer, b_equalizer );
574 var_AddCallback( pAout, "equalizer-bands",
575 onEqBandsChange, this );
576 var_AddCallback( pAout, "equalizer-preamp",
577 onEqPreampChange, this );
578 m_bEqualizer_started = true;
584 case INPUT_EVENT_CHAPTER:
586 vlc_value_t chapters_count;
587 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
588 &chapters_count, NULL );
589 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
593 case INPUT_EVENT_RECORD:
594 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
597 case INPUT_EVENT_DEAD:
598 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
600 var_DelCallback( pInput, "intf-event", onGenericCallback2, this );
601 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
602 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
603 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
604 vlc_object_release( pInput );
605 getIntf()->p_sys->p_input = NULL;
614 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
617 input_thread_t* pInput = (input_thread_t*) p_obj;
619 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
621 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
622 SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
625 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
628 input_thread_t* pInput = (input_thread_t*) p_obj;
630 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
632 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
633 SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
636 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
639 input_thread_t* pInput = (input_thread_t*) p_obj;
641 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
643 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
646 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
649 playlist_t* pPlaylist = (playlist_t*) p_obj;
651 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
654 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
657 playlist_t* pPlaylist = (playlist_t*) p_obj;
659 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
662 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
665 playlist_t* pPlaylist = (playlist_t*) p_obj;
667 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
670 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
672 (void)p_obj; (void)newVal;
673 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
675 SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
678 void VlcProc::on_mute_changed( vlc_object_t* p_obj, vlc_value_t newVal )
681 SET_BOOL( m_cVarMute, newVal.b_bool );
684 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
687 audio_output_t* pAout = (audio_output_t*) p_obj;
689 char *pFilters = newVal.psz_string;
691 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
692 SET_BOOL( m_cVarEqualizer, b_equalizer );
693 if( b_equalizer && !m_bEqualizer_started )
695 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
696 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
697 m_bEqualizer_started = true;
701 void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
703 (void)p_obj; (void)newVal;
704 bool b_fullscreen = getFullscreenVar().get();
710 // Create a raise all command
711 CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
712 getIntf()->p_sys->p_theme->getWindowManager() );
714 // Push the command in the asynchronous command queue
715 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
716 pQueue->push( CmdGenericPtr( pCmd ) );
721 VoutManager* pVoutManager = VoutManager::instance( getIntf() );
722 FscWindow *pWin = pVoutManager->getFscWindow();
725 bool b_visible = pWin->getVisibleVar().get();
726 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
730 CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
731 getIntf()->p_sys->p_theme->getWindowManager(),
733 pQueue->push( CmdGenericPtr( pCmd ) );
737 CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
738 getIntf()->p_sys->p_theme->getWindowManager(),
740 pQueue->push( CmdGenericPtr( pCmd ) );
746 void VlcProc::on_mouse_moved_changed( vlc_object_t* p_obj, vlc_value_t newVal )
748 (void)p_obj; (void)newVal;
749 FscWindow* pFscWindow = VoutManager::instance( getIntf() )->getFscWindow();
751 pFscWindow->onMouseMoved();
754 void VlcProc::reset_input()
756 SET_BOOL( m_cVarSeekable, false );
757 SET_BOOL( m_cVarRecordable, false );
758 SET_BOOL( m_cVarRecording, false );
759 SET_BOOL( m_cVarDvdActive, false );
760 SET_BOOL( m_cVarHasAudio, false );
761 SET_BOOL( m_cVarHasVout, false );
762 SET_BOOL( m_cVarStopped, true );
763 SET_BOOL( m_cVarPlaying, false );
764 SET_BOOL( m_cVarPaused, false );
766 SET_STREAMTIME( m_cVarTime, 0, false );
767 SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
768 SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
769 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
770 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
772 getPlaytreeVar().onUpdateCurrent( false );
775 void VlcProc::init_variables()
777 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
779 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
780 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
781 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
783 SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
784 SET_BOOL( m_cVarMute, var_GetBool( pPlaylist, "mute" ) );
790 void VlcProc::update_current_input()
792 input_thread_t* pInput = getIntf()->p_sys->p_input;
796 input_item_t *pItem = input_GetItem( pInput );
800 char *psz_name = input_item_GetTitle( pItem );
801 if( EMPTY_STR( psz_name ) )
804 psz_name = input_item_GetName( pItem );
807 psz_name = strdup ( "" );
808 SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
811 // Update local path (if possible) or full uri
812 char *psz_uri = input_item_GetURI( pItem );
813 char *psz_path = make_path( psz_uri );
814 char *psz_save = psz_path ? psz_path : psz_uri;
815 SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
820 char *psz_art = input_item_GetArtURL( pItem );
821 SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
826 void VlcProc::update_equalizer()
831 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
833 pFilters = var_InheritString( getIntf(), "audio-filter" );
835 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
838 SET_BOOL( m_cVarEqualizer, b_equalizer );
841 void VlcProc::setFullscreenVar( bool b_fullscreen )
843 SET_BOOL( m_cVarFullscreen, b_fullscreen );
847 #undef SET_STREAMTIME