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>
35 #include "vlcproc.hpp"
36 #include "os_factory.hpp"
37 #include "os_loop.hpp"
38 #include "os_timer.hpp"
39 #include "var_manager.hpp"
40 #include "vout_manager.hpp"
42 #include "window_manager.hpp"
43 #include "../commands/async_queue.hpp"
44 #include "../commands/cmd_change_skin.hpp"
45 #include "../commands/cmd_show_window.hpp"
46 #include "../commands/cmd_quit.hpp"
47 #include "../commands/cmd_resize.hpp"
48 #include "../commands/cmd_vars.hpp"
49 #include "../commands/cmd_dialogs.hpp"
50 #include "../commands/cmd_audio.hpp"
51 #include "../commands/cmd_callbacks.hpp"
52 #include "../utils/var_bool.hpp"
53 #include "../utils/var_string.hpp"
58 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
60 if( pIntf->p_sys->p_vlcProc == NULL )
62 pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
65 return pIntf->p_sys->p_vlcProc;
69 void VlcProc::destroy( intf_thread_t *pIntf )
71 delete pIntf->p_sys->p_vlcProc;
72 pIntf->p_sys->p_vlcProc = NULL;
76 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
77 m_varEqBands( pIntf ), m_pVout( NULL ), m_pAout( NULL ),
78 m_bEqualizer_started( false ), m_cmdManage( this )
80 // Create a timer to poll the status of the vlc
81 OSFactory *pOsFactory = OSFactory::instance( pIntf );
82 m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
83 m_pTimer->start( 100, false );
85 // Create and register VLC variables
86 VarManager *pVarManager = VarManager::instance( getIntf() );
88 #define REGISTER_VAR( var, type, name ) \
89 var = VariablePtr( new type( getIntf() ) ); \
90 pVarManager->registerVar( var, name );
91 REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
92 REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
93 REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
94 REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
95 pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
97 pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
98 pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
100 REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
101 REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
102 REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
104 /* Input variables */
105 pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
106 REGISTER_VAR( m_cVarTime, StreamTime, "time" )
107 REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
108 REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
110 REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" )
111 REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" )
114 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
115 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
118 REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
119 REGISTER_VAR( m_cVarVolume, Volume, "volume" )
120 REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
121 REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
122 REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
125 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
126 pVarManager->registerVar( m_cVarStreamName, "streamName" );
127 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
128 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
129 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
130 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
131 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
132 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
133 m_cVarStreamArt = VariablePtr( new VarString( getIntf() ) );
134 pVarManager->registerVar( m_cVarStreamArt, "streamArt" );
136 // Register the equalizer bands
137 for( int i = 0; i < EqualizerBands::kNbBands; i++)
140 ss << "equalizer.band(" << i << ")";
141 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
145 // The object variable callbacks are called from other VLC threads,
146 // so they must put commands in the queue and NOT do anything else
147 // (X11 calls are not reentrant)
149 #define ADD_CALLBACK( p_object, var ) \
150 var_AddCallback( p_object, var, onGenericCallback, this );
152 ADD_CALLBACK( pIntf->p_sys->p_playlist, "volume-change" )
153 ADD_CALLBACK( pIntf->p_libvlc, "intf-show" )
155 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
156 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
157 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
158 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
162 // Called when a playlist item is added
163 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
164 onItemAppend, this );
165 // Called when a playlist item is deleted
166 // TODO: properly handle item-deleted
167 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
168 onItemDelete, this );
169 // Called when the current input changes
170 var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
172 // Called when a playlist item changed
173 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
174 onItemChange, this );
176 // Called when we have an interaction dialog to display
177 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
178 var_AddCallback( pIntf, "interaction", onInteraction, this );
179 interaction_Register( pIntf );
181 // initialize variables refering to liblvc and playlist objects
193 vlc_object_release( m_pAout );
198 vlc_object_release( m_pVout );
202 interaction_Unregister( getIntf() );
204 var_DelCallback( getIntf()->p_sys->p_playlist, "volume-change",
205 onGenericCallback, this );
206 var_DelCallback( getIntf()->p_libvlc, "intf-show",
207 onGenericCallback, this );
209 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
210 onGenericCallback, this );
211 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
212 onGenericCallback, this );
213 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
214 onGenericCallback, this );
215 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
216 onGenericCallback, this );
218 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
219 onItemAppend, this );
220 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
221 onItemDelete, this );
222 var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
224 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
225 onItemChange, this );
226 var_DelCallback( getIntf(), "interaction", onInteraction, this );
229 void VlcProc::manage()
231 // Did the user request to quit vlc ?
232 if( !vlc_object_alive( getIntf() ) )
234 // Get the instance of OSFactory
235 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
237 // Exit the main OS loop
238 pOsFactory->getOSLoop()->exit();
244 void VlcProc::CmdManage::execute()
246 // Just forward to VlcProc
251 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
252 vlc_value_t oldval, vlc_value_t newval, void *pParam )
254 VlcProc *pThis = (VlcProc*)pParam;
255 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
257 var_AddCallback( pInput, "intf-event", onGenericCallback2, pThis );
258 var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
259 var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
260 var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
266 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
267 vlc_value_t oldval, vlc_value_t newval,
270 VlcProc *pThis = (VlcProc*)pParam;
271 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
273 // Create a playtree notify command
274 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
277 // Push the command in the asynchronous command queue
278 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
279 pQueue->push( CmdGenericPtr( pCmdTree ), true );
284 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
285 vlc_value_t oldVal, vlc_value_t newVal,
288 VlcProc *pThis = (VlcProc*)pParam;
290 playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
292 CmdGenericPtr ptrTree;
293 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
295 ptrTree = CmdGenericPtr( pCmdTree );
297 // Push the command in the asynchronous command queue
298 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
299 pQueue->push( ptrTree , false );
304 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
305 vlc_value_t oldVal, vlc_value_t newVal,
308 VlcProc *pThis = (VlcProc*)pParam;
310 int i_id = newVal.i_int;
312 CmdGenericPtr ptrTree;
313 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
315 ptrTree = CmdGenericPtr( pCmdTree );
317 // Push the command in the asynchronous command queue
318 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
319 pQueue->push( ptrTree , false );
324 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
325 vlc_value_t oldVal, vlc_value_t newVal,
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 VlcProc *pThis = (VlcProc*)pParam;
343 // Post a set equalizer bands command
344 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
347 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
348 pQueue->push( CmdGenericPtr( pCmd ) );
354 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
355 vlc_value_t oldVal, vlc_value_t newVal,
358 VlcProc *pThis = (VlcProc*)pParam;
359 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
361 // Post a set preamp command
362 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
363 (newVal.f_float + 20.0) / 40.0 );
364 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
365 pQueue->push( CmdGenericPtr( pCmd ) );
371 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
372 vlc_value_t oldVal, vlc_value_t newVal,
375 VlcProc *pThis = (VlcProc*)pParam;
376 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
378 #define ADD_CALLBACK_ENTRY( var, func, remove ) \
380 if( strcmp( pVariable, var ) == 0 ) \
382 string label = var; \
383 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal, \
384 &VlcProc::func, label ); \
386 pQueue->push( CmdGenericPtr( pCmd ), remove ); \
387 return VLC_SUCCESS; \
391 ADD_CALLBACK_ENTRY( "item-current", on_item_current_changed, false )
392 ADD_CALLBACK_ENTRY( "volume-change", on_volume_changed, true )
394 ADD_CALLBACK_ENTRY( "bit-rate", on_bit_rate_changed, false )
395 ADD_CALLBACK_ENTRY( "sample-rate", on_sample_rate_changed, false )
396 ADD_CALLBACK_ENTRY( "can-record", on_can_record_changed, false )
398 ADD_CALLBACK_ENTRY( "random", on_random_changed, false )
399 ADD_CALLBACK_ENTRY( "loop", on_loop_changed, false )
400 ADD_CALLBACK_ENTRY( "repeat", on_repeat_changed, false )
402 ADD_CALLBACK_ENTRY( "audio-filter", on_audio_filter_changed, false )
404 ADD_CALLBACK_ENTRY( "intf-show", on_intf_show_changed, false )
406 #undef ADD_CALLBACK_ENTRY
408 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
413 int VlcProc::onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
414 vlc_value_t oldVal, vlc_value_t newVal,
417 VlcProc *pThis = (VlcProc*)pParam;
418 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
421 * For intf-event, commands are labeled based on the value of newVal.
423 * For some values (e.g position), only keep the latest command
424 * when there are multiple pending commands (remove=true).
426 * for others, don't discard commands (remove=false)
428 if( strcmp( pVariable, "intf-event" ) == 0 )
432 switch( newVal.i_int )
434 case INPUT_EVENT_STATE:
435 case INPUT_EVENT_POSITION:
437 case INPUT_EVENT_CHAPTER:
438 case INPUT_EVENT_RECORD:
441 case INPUT_EVENT_VOUT:
442 case INPUT_EVENT_AOUT:
443 case INPUT_EVENT_DEAD:
449 label << pVariable << "_" << newVal.i_int;
450 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal,
451 &VlcProc::on_intf_event_changed,
454 pQueue->push( CmdGenericPtr( pCmd ), b_remove );
459 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
464 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
465 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
466 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
467 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
468 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
470 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
472 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
475 char *psz_name = input_item_GetName( p_item );
476 SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
480 char *psz_uri = input_item_GetURI( p_item );
481 SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_uri ) );
485 char *psz_art = input_item_GetArtURL( p_item );
486 SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
490 getPlaytreeVar().onUpdateCurrent( true );
493 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
495 input_thread_t* pInput = (input_thread_t*) p_obj;
497 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
499 if( !getIntf()->p_sys->p_input )
501 msg_Dbg( getIntf(), "new input %p detected", pInput );
503 getIntf()->p_sys->p_input = pInput;
504 vlc_object_hold( pInput );
507 switch( newVal.i_int )
509 case INPUT_EVENT_STATE:
511 int state = var_GetInteger( pInput, "state" );
512 SET_BOOL( m_cVarStopped, false );
513 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
514 SET_BOOL( m_cVarPaused, state == PAUSE_S );
518 case INPUT_EVENT_POSITION:
520 float pos = var_GetFloat( pInput, "position" );
521 SET_STREAMTIME( m_cVarTime, pos, false );
522 SET_BOOL( m_cVarSeekable, pos != 0.0 );
529 vlc_value_t audio_es;
530 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
532 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
536 case INPUT_EVENT_VOUT:
538 vout_thread_t* pVout = input_GetVout( pInput );
539 SET_BOOL( m_cVarHasVout, pVout != NULL );
541 vlc_object_release( pVout );
545 case INPUT_EVENT_AOUT:
547 aout_instance_t* pAout = input_GetAout( pInput );
549 // end of input or aout reuse (nothing to do)
550 if( !pAout || pAout == m_pAout )
553 vlc_object_release( pAout );
557 // remove previous Aout if any
560 var_DelCallback( m_pAout, "audio-filter",
561 onGenericCallback, this );
562 if( m_bEqualizer_started )
564 var_DelCallback( m_pAout, "equalizer-bands",
565 onEqBandsChange, this );
566 var_DelCallback( m_pAout, "equalizer-preamp",
567 onEqPreampChange, this );
569 vlc_object_release( m_pAout );
571 m_bEqualizer_started = false;
574 // New Aout (addCallbacks)
575 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
577 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
578 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
580 SET_BOOL( m_cVarEqualizer, b_equalizer );
583 var_AddCallback( pAout, "equalizer-bands",
584 onEqBandsChange, this );
585 var_AddCallback( pAout, "equalizer-preamp",
586 onEqPreampChange, this );
587 m_bEqualizer_started = true;
593 case INPUT_EVENT_CHAPTER:
595 vlc_value_t chapters_count;
596 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
597 &chapters_count, NULL );
598 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
602 case INPUT_EVENT_RECORD:
603 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
606 case INPUT_EVENT_DEAD:
607 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
609 var_DelCallback( pInput, "intf-event", onGenericCallback2, this );
610 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
611 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
612 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
613 vlc_object_release( pInput );
614 getIntf()->p_sys->p_input = NULL;
623 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
625 input_thread_t* pInput = (input_thread_t*) p_obj;
627 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
629 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
630 SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
633 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
635 input_thread_t* pInput = (input_thread_t*) p_obj;
637 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
639 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
640 SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
643 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
645 input_thread_t* pInput = (input_thread_t*) p_obj;
647 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
649 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
652 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
654 playlist_t* pPlaylist = (playlist_t*) p_obj;
656 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
659 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
661 playlist_t* pPlaylist = (playlist_t*) p_obj;
663 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
666 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
668 playlist_t* pPlaylist = (playlist_t*) p_obj;
670 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
673 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
675 (void)p_obj; (void)newVal;
676 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
678 audio_volume_t volume;
679 aout_VolumeGet( pPlaylist, &volume );
680 SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
681 SET_BOOL( m_cVarMute, volume == 0 );
684 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
686 aout_instance_t* pAout = (aout_instance_t*) p_obj;
688 char *pFilters = newVal.psz_string;
690 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
691 SET_BOOL( m_cVarEqualizer, b_equalizer );
692 if( b_equalizer && !m_bEqualizer_started )
694 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
695 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
696 m_bEqualizer_started = true;
700 void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
703 bool b_fullscreen = getFullscreenVar().get();
709 // Create a raise all command
710 CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
711 getIntf()->p_sys->p_theme->getWindowManager() );
713 // Push the command in the asynchronous command queue
714 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
715 pQueue->push( CmdGenericPtr( pCmd ) );
720 Theme* pTheme = getIntf()->p_sys->p_theme;
721 TopWindow *pWin = pTheme->getWindowById( "fullscreenController" );
724 bool b_visible = pWin->getVisibleVar().get();
725 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
729 CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
730 getIntf()->p_sys->p_theme->getWindowManager(),
732 pQueue->push( CmdGenericPtr( pCmd ) );
736 CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
737 getIntf()->p_sys->p_theme->getWindowManager(),
739 pQueue->push( CmdGenericPtr( pCmd ) );
745 void VlcProc::reset_input()
747 SET_BOOL( m_cVarSeekable, false );
748 SET_BOOL( m_cVarRecordable, false );
749 SET_BOOL( m_cVarRecording, false );
750 SET_BOOL( m_cVarDvdActive, false );
751 SET_BOOL( m_cVarHasAudio, false );
752 SET_BOOL( m_cVarHasVout, false );
753 SET_BOOL( m_cVarStopped, true );
754 SET_BOOL( m_cVarPlaying, false );
755 SET_BOOL( m_cVarPaused, false );
757 SET_STREAMTIME( m_cVarTime, 0, false );
758 SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
759 SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
760 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
761 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
763 getPlaytreeVar().onUpdateCurrent( false );
766 void VlcProc::init_variables()
768 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
770 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
771 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
772 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
774 audio_volume_t volume;
775 aout_VolumeGet( pPlaylist, &volume );
776 SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
777 SET_BOOL( m_cVarMute, volume == 0 );
782 void VlcProc::update_equalizer()
787 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
789 pFilters = var_InheritString( getIntf(), "audio-filter" );
791 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
794 SET_BOOL( m_cVarEqualizer, b_equalizer );
797 void VlcProc::setFullscreenVar( bool b_fullscreen )
799 SET_BOOL( m_cVarFullscreen, b_fullscreen );
803 #undef SET_STREAMTIME