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-change" )
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 );
181 interaction_Register( pIntf );
183 // initialize variables refering to liblvc and playlist objects
195 vlc_object_release( m_pAout );
200 vlc_object_release( m_pVout );
204 interaction_Unregister( getIntf() );
206 var_DelCallback( getIntf()->p_sys->p_playlist, "volume-change",
207 onGenericCallback, this );
208 var_DelCallback( getIntf()->p_libvlc, "intf-show",
209 onGenericCallback, this );
211 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
212 onGenericCallback, this );
213 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
214 onGenericCallback, this );
215 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
216 onGenericCallback, this );
217 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
218 onGenericCallback, this );
220 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
221 onItemAppend, this );
222 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
223 onItemDelete, this );
224 var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
226 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
227 onItemChange, this );
228 var_DelCallback( getIntf(), "interaction", onInteraction, this );
231 void VlcProc::manage()
233 // Did the user request to quit vlc ?
234 if( !vlc_object_alive( getIntf() ) )
236 // Get the instance of OSFactory
237 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
239 // Exit the main OS loop
240 pOsFactory->getOSLoop()->exit();
246 void VlcProc::CmdManage::execute()
248 // Just forward to VlcProc
253 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
254 vlc_value_t oldval, vlc_value_t newval, void *pParam )
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 VlcProc *pThis = (VlcProc*)pParam;
273 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
275 // Create a playtree notify command
276 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
279 // Push the command in the asynchronous command queue
280 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
281 pQueue->push( CmdGenericPtr( pCmdTree ), true );
286 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
287 vlc_value_t oldVal, vlc_value_t newVal,
290 VlcProc *pThis = (VlcProc*)pParam;
292 playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
293 CmdPlaytreeAppend *pCmdTree =
294 new CmdPlaytreeAppend( pThis->getIntf(), p_add );
296 // Push the command in the asynchronous command queue
297 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
298 pQueue->push( CmdGenericPtr( pCmdTree ), false );
303 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
304 vlc_value_t oldVal, vlc_value_t newVal,
307 VlcProc *pThis = (VlcProc*)pParam;
309 int i_id = newVal.i_int;
310 CmdPlaytreeDelete *pCmdTree =
311 new CmdPlaytreeDelete( pThis->getIntf(), i_id);
313 // Push the command in the asynchronous command queue
314 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
315 pQueue->push( CmdGenericPtr( pCmdTree ), false );
320 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
321 vlc_value_t oldVal, vlc_value_t newVal,
324 VlcProc *pThis = (VlcProc*)pParam;
325 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
327 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
328 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
329 pQueue->push( CmdGenericPtr( pCmd ) );
333 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
334 vlc_value_t oldVal, vlc_value_t newVal,
337 VlcProc *pThis = (VlcProc*)pParam;
339 // Post a set equalizer bands command
340 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
343 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
344 pQueue->push( CmdGenericPtr( pCmd ) );
350 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
351 vlc_value_t oldVal, vlc_value_t newVal,
354 VlcProc *pThis = (VlcProc*)pParam;
355 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
357 // Post a set preamp command
358 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
359 (newVal.f_float + 20.0) / 40.0 );
360 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
361 pQueue->push( CmdGenericPtr( pCmd ) );
367 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
368 vlc_value_t oldVal, vlc_value_t newVal,
371 VlcProc *pThis = (VlcProc*)pParam;
372 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
374 #define ADD_CALLBACK_ENTRY( var, func, remove ) \
376 if( strcmp( pVariable, var ) == 0 ) \
378 string label = var; \
379 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal, \
380 &VlcProc::func, label ); \
382 pQueue->push( CmdGenericPtr( pCmd ), remove ); \
383 return VLC_SUCCESS; \
387 ADD_CALLBACK_ENTRY( "item-current", on_item_current_changed, false )
388 ADD_CALLBACK_ENTRY( "volume-change", on_volume_changed, true )
390 ADD_CALLBACK_ENTRY( "bit-rate", on_bit_rate_changed, false )
391 ADD_CALLBACK_ENTRY( "sample-rate", on_sample_rate_changed, false )
392 ADD_CALLBACK_ENTRY( "can-record", on_can_record_changed, false )
394 ADD_CALLBACK_ENTRY( "random", on_random_changed, false )
395 ADD_CALLBACK_ENTRY( "loop", on_loop_changed, false )
396 ADD_CALLBACK_ENTRY( "repeat", on_repeat_changed, false )
398 ADD_CALLBACK_ENTRY( "audio-filter", on_audio_filter_changed, false )
400 ADD_CALLBACK_ENTRY( "intf-show", on_intf_show_changed, false )
402 ADD_CALLBACK_ENTRY( "mouse-moved", on_mouse_moved_changed, false )
404 #undef ADD_CALLBACK_ENTRY
406 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
411 int VlcProc::onGenericCallback2( vlc_object_t *pObj, const char *pVariable,
412 vlc_value_t oldVal, vlc_value_t newVal,
415 VlcProc *pThis = (VlcProc*)pParam;
416 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
419 * For intf-event, commands are labeled based on the value of newVal.
421 * For some values (e.g position), only keep the latest command
422 * when there are multiple pending commands (remove=true).
424 * for others, don't discard commands (remove=false)
426 if( strcmp( pVariable, "intf-event" ) == 0 )
430 switch( newVal.i_int )
432 case INPUT_EVENT_STATE:
433 case INPUT_EVENT_POSITION:
435 case INPUT_EVENT_CHAPTER:
436 case INPUT_EVENT_RECORD:
439 case INPUT_EVENT_VOUT:
440 case INPUT_EVENT_AOUT:
441 case INPUT_EVENT_DEAD:
447 label << pVariable << "_" << newVal.i_int;
448 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal,
449 &VlcProc::on_intf_event_changed,
452 pQueue->push( CmdGenericPtr( pCmd ), b_remove );
457 msg_Err( pThis->getIntf(), "no callback entry for %s", pVariable );
462 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
463 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
464 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
465 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
466 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
468 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
470 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
473 char *psz_name = input_item_GetName( p_item );
474 SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
477 // Update local path (if possible) or full uri
478 char *psz_uri = input_item_GetURI( p_item );
479 char *psz_path = make_path( psz_uri );
480 char *psz_save = psz_path ? psz_path : psz_uri;
481 SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
486 char *psz_art = input_item_GetArtURL( p_item );
487 SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
491 getPlaytreeVar().onUpdateCurrent( true );
494 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
496 input_thread_t* pInput = (input_thread_t*) p_obj;
498 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
500 if( !getIntf()->p_sys->p_input )
502 msg_Dbg( getIntf(), "new input %p detected", pInput );
504 getIntf()->p_sys->p_input = pInput;
505 vlc_object_hold( pInput );
508 switch( newVal.i_int )
510 case INPUT_EVENT_STATE:
512 int state = var_GetInteger( pInput, "state" );
513 SET_BOOL( m_cVarStopped, false );
514 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
515 SET_BOOL( m_cVarPaused, state == PAUSE_S );
519 case INPUT_EVENT_POSITION:
521 float pos = var_GetFloat( pInput, "position" );
522 SET_STREAMTIME( m_cVarTime, pos, false );
523 SET_BOOL( m_cVarSeekable, pos != 0.0 );
530 vlc_value_t audio_es;
531 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
533 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
537 case INPUT_EVENT_VOUT:
539 vout_thread_t* pVout = input_GetVout( pInput );
540 SET_BOOL( m_cVarHasVout, pVout != NULL );
541 if( !pVout || pVout == m_pVout )
543 // end of input or vout reuse (nothing to do)
545 vlc_object_release( pVout );
550 // remove previous Vout callbacks
551 var_DelCallback( m_pVout, "mouse-moved",
552 onGenericCallback, this );
553 vlc_object_release( m_pVout );
557 // add new Vout callbackx
558 var_AddCallback( pVout, "mouse-moved",
559 onGenericCallback, this );
564 case INPUT_EVENT_AOUT:
566 aout_instance_t* pAout = input_GetAout( pInput );
568 // end of input or aout reuse (nothing to do)
569 if( !pAout || pAout == m_pAout )
572 vlc_object_release( pAout );
576 // remove previous Aout if any
579 var_DelCallback( m_pAout, "audio-filter",
580 onGenericCallback, this );
581 if( m_bEqualizer_started )
583 var_DelCallback( m_pAout, "equalizer-bands",
584 onEqBandsChange, this );
585 var_DelCallback( m_pAout, "equalizer-preamp",
586 onEqPreampChange, this );
588 vlc_object_release( m_pAout );
590 m_bEqualizer_started = false;
593 // New Aout (addCallbacks)
594 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
596 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
597 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
599 SET_BOOL( m_cVarEqualizer, b_equalizer );
602 var_AddCallback( pAout, "equalizer-bands",
603 onEqBandsChange, this );
604 var_AddCallback( pAout, "equalizer-preamp",
605 onEqPreampChange, this );
606 m_bEqualizer_started = true;
612 case INPUT_EVENT_CHAPTER:
614 vlc_value_t chapters_count;
615 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
616 &chapters_count, NULL );
617 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
621 case INPUT_EVENT_RECORD:
622 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
625 case INPUT_EVENT_DEAD:
626 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
628 var_DelCallback( pInput, "intf-event", onGenericCallback2, this );
629 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
630 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
631 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
632 vlc_object_release( pInput );
633 getIntf()->p_sys->p_input = NULL;
642 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
644 input_thread_t* pInput = (input_thread_t*) p_obj;
646 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
648 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
649 SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
652 void VlcProc::on_sample_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 sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
659 SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
662 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
664 input_thread_t* pInput = (input_thread_t*) p_obj;
666 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
668 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
671 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
673 playlist_t* pPlaylist = (playlist_t*) p_obj;
675 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
678 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
680 playlist_t* pPlaylist = (playlist_t*) p_obj;
682 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
685 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
687 playlist_t* pPlaylist = (playlist_t*) p_obj;
689 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
692 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
694 (void)p_obj; (void)newVal;
695 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
697 audio_volume_t volume;
698 aout_VolumeGet( pPlaylist, &volume );
699 SET_VOLUME( m_cVarVolume, volume, false );
700 SET_BOOL( m_cVarMute, volume == 0 );
703 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
705 aout_instance_t* pAout = (aout_instance_t*) p_obj;
707 char *pFilters = newVal.psz_string;
709 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
710 SET_BOOL( m_cVarEqualizer, b_equalizer );
711 if( b_equalizer && !m_bEqualizer_started )
713 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
714 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
715 m_bEqualizer_started = true;
719 void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
722 bool b_fullscreen = getFullscreenVar().get();
728 // Create a raise all command
729 CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
730 getIntf()->p_sys->p_theme->getWindowManager() );
732 // Push the command in the asynchronous command queue
733 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
734 pQueue->push( CmdGenericPtr( pCmd ) );
739 VoutManager* pVoutManager = VoutManager::instance( getIntf() );
740 FscWindow *pWin = pVoutManager->getFscWindow();
743 bool b_visible = pWin->getVisibleVar().get();
744 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
748 CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
749 getIntf()->p_sys->p_theme->getWindowManager(),
751 pQueue->push( CmdGenericPtr( pCmd ) );
755 CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
756 getIntf()->p_sys->p_theme->getWindowManager(),
758 pQueue->push( CmdGenericPtr( pCmd ) );
764 void VlcProc::on_mouse_moved_changed( vlc_object_t* p_obj, vlc_value_t newVal )
766 FscWindow* pFscWindow = VoutManager::instance( getIntf() )->getFscWindow();
768 pFscWindow->onMouseMoved();
771 void VlcProc::reset_input()
773 SET_BOOL( m_cVarSeekable, false );
774 SET_BOOL( m_cVarRecordable, false );
775 SET_BOOL( m_cVarRecording, false );
776 SET_BOOL( m_cVarDvdActive, false );
777 SET_BOOL( m_cVarHasAudio, false );
778 SET_BOOL( m_cVarHasVout, false );
779 SET_BOOL( m_cVarStopped, true );
780 SET_BOOL( m_cVarPlaying, false );
781 SET_BOOL( m_cVarPaused, false );
783 SET_STREAMTIME( m_cVarTime, 0, false );
784 SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
785 SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
786 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
787 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
789 getPlaytreeVar().onUpdateCurrent( false );
792 void VlcProc::init_variables()
794 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
796 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
797 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
798 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
800 audio_volume_t volume;
801 aout_VolumeGet( pPlaylist, &volume );
802 SET_VOLUME( m_cVarVolume, volume, false );
803 SET_BOOL( m_cVarMute, volume == 0 );
808 void VlcProc::update_equalizer()
813 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
815 pFilters = var_InheritString( getIntf(), "audio-filter" );
817 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
820 SET_BOOL( m_cVarEqualizer, b_equalizer );
823 void VlcProc::setFullscreenVar( bool b_fullscreen )
825 SET_BOOL( m_cVarFullscreen, b_fullscreen );
829 #undef SET_STREAMTIME