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>
32 #include <vlc_aout_intf.h>
34 #include <vlc_playlist.h>
37 #include "vlcproc.hpp"
38 #include "os_factory.hpp"
39 #include "os_loop.hpp"
40 #include "os_timer.hpp"
41 #include "var_manager.hpp"
42 #include "vout_manager.hpp"
43 #include "fsc_window.hpp"
45 #include "window_manager.hpp"
46 #include "../commands/async_queue.hpp"
47 #include "../commands/cmd_change_skin.hpp"
48 #include "../commands/cmd_show_window.hpp"
49 #include "../commands/cmd_quit.hpp"
50 #include "../commands/cmd_resize.hpp"
51 #include "../commands/cmd_vars.hpp"
52 #include "../commands/cmd_dialogs.hpp"
53 #include "../commands/cmd_audio.hpp"
54 #include "../commands/cmd_callbacks.hpp"
55 #include "../utils/var_bool.hpp"
56 #include "../utils/var_string.hpp"
61 VlcProc
*VlcProc::instance( intf_thread_t
*pIntf
)
63 if( pIntf
->p_sys
->p_vlcProc
== NULL
)
65 pIntf
->p_sys
->p_vlcProc
= new VlcProc( pIntf
);
68 return pIntf
->p_sys
->p_vlcProc
;
72 void VlcProc::destroy( intf_thread_t
*pIntf
)
74 delete pIntf
->p_sys
->p_vlcProc
;
75 pIntf
->p_sys
->p_vlcProc
= NULL
;
79 VlcProc::VlcProc( intf_thread_t
*pIntf
): SkinObject( pIntf
),
80 m_varEqBands( pIntf
), m_pVout( NULL
), m_pAout( NULL
),
81 m_bEqualizer_started( false ), m_cmdManage( this )
83 // Create a timer to poll the status of the vlc
84 OSFactory
*pOsFactory
= OSFactory::instance( pIntf
);
85 m_pTimer
= pOsFactory
->createOSTimer( m_cmdManage
);
86 m_pTimer
->start( 100, false );
88 // Create and register VLC variables
89 VarManager
*pVarManager
= VarManager::instance( getIntf() );
91 #define REGISTER_VAR( var, type, name ) \
92 var = VariablePtr( new type( getIntf() ) ); \
93 pVarManager->registerVar( var, name );
94 REGISTER_VAR( m_cVarRandom
, VarBoolImpl
, "playlist.isRandom" )
95 REGISTER_VAR( m_cVarLoop
, VarBoolImpl
, "playlist.isLoop" )
96 REGISTER_VAR( m_cVarRepeat
, VarBoolImpl
, "playlist.isRepeat" )
97 REGISTER_VAR( m_cPlaytree
, Playtree
, "playtree" )
98 pVarManager
->registerVar( getPlaytreeVar().getPositionVarPtr(),
100 pVarManager
->registerVar( m_cVarRandom
, "playtree.isRandom" );
101 pVarManager
->registerVar( m_cVarLoop
, "playtree.isLoop" );
103 REGISTER_VAR( m_cVarPlaying
, VarBoolImpl
, "vlc.isPlaying" )
104 REGISTER_VAR( m_cVarStopped
, VarBoolImpl
, "vlc.isStopped" )
105 REGISTER_VAR( m_cVarPaused
, VarBoolImpl
, "vlc.isPaused" )
107 /* Input variables */
108 pVarManager
->registerVar( m_cVarRepeat
, "playtree.isRepeat" );
109 REGISTER_VAR( m_cVarTime
, StreamTime
, "time" )
110 REGISTER_VAR( m_cVarSeekable
, VarBoolImpl
, "vlc.isSeekable" )
111 REGISTER_VAR( m_cVarDvdActive
, VarBoolImpl
, "dvd.isActive" )
113 REGISTER_VAR( m_cVarRecordable
, VarBoolImpl
, "vlc.canRecord" )
114 REGISTER_VAR( m_cVarRecording
, VarBoolImpl
, "vlc.isRecording" )
117 REGISTER_VAR( m_cVarFullscreen
, VarBoolImpl
, "vlc.isFullscreen" )
118 REGISTER_VAR( m_cVarHasVout
, VarBoolImpl
, "vlc.hasVout" )
121 REGISTER_VAR( m_cVarHasAudio
, VarBoolImpl
, "vlc.hasAudio" )
122 REGISTER_VAR( m_cVarVolume
, Volume
, "volume" )
123 REGISTER_VAR( m_cVarMute
, VarBoolImpl
, "vlc.isMute" )
124 REGISTER_VAR( m_cVarEqualizer
, VarBoolImpl
, "equalizer.isEnabled" )
125 REGISTER_VAR( m_cVarEqPreamp
, EqualizerPreamp
, "equalizer.preamp" )
128 m_cVarStreamName
= VariablePtr( new VarText( getIntf(), false ) );
129 pVarManager
->registerVar( m_cVarStreamName
, "streamName" );
130 m_cVarStreamURI
= VariablePtr( new VarText( getIntf(), false ) );
131 pVarManager
->registerVar( m_cVarStreamURI
, "streamURI" );
132 m_cVarStreamBitRate
= VariablePtr( new VarText( getIntf(), false ) );
133 pVarManager
->registerVar( m_cVarStreamBitRate
, "bitrate" );
134 m_cVarStreamSampleRate
= VariablePtr( new VarText( getIntf(), false ) );
135 pVarManager
->registerVar( m_cVarStreamSampleRate
, "samplerate" );
136 m_cVarStreamArt
= VariablePtr( new VarString( getIntf() ) );
137 pVarManager
->registerVar( m_cVarStreamArt
, "streamArt" );
139 // Register the equalizer bands
140 for( int i
= 0; i
< EqualizerBands::kNbBands
; i
++)
143 ss
<< "equalizer.band(" << i
<< ")";
144 pVarManager
->registerVar( m_varEqBands
.getBand( i
), ss
.str() );
148 // The object variable callbacks are called from other VLC threads,
149 // so they must put commands in the queue and NOT do anything else
150 // (X11 calls are not reentrant)
152 #define ADD_CALLBACK( p_object, var ) \
153 var_AddCallback( p_object, var, onGenericCallback, this );
155 ADD_CALLBACK( pIntf
->p_sys
->p_playlist
, "volume" )
156 ADD_CALLBACK( pIntf
->p_libvlc
, "intf-toggle-fscontrol" )
158 ADD_CALLBACK( pIntf
->p_sys
->p_playlist
, "item-current" )
159 ADD_CALLBACK( pIntf
->p_sys
->p_playlist
, "random" )
160 ADD_CALLBACK( pIntf
->p_sys
->p_playlist
, "loop" )
161 ADD_CALLBACK( pIntf
->p_sys
->p_playlist
, "repeat" )
165 // Called when a playlist item is added
166 var_AddCallback( pIntf
->p_sys
->p_playlist
, "playlist-item-append",
167 onItemAppend
, this );
168 // Called when a playlist item is deleted
169 // TODO: properly handle item-deleted
170 var_AddCallback( pIntf
->p_sys
->p_playlist
, "playlist-item-deleted",
171 onItemDelete
, this );
172 // Called when the current input changes
173 var_AddCallback( pIntf
->p_sys
->p_playlist
, "input-current",
175 // Called when a playlist item changed
176 var_AddCallback( pIntf
->p_sys
->p_playlist
, "item-change",
177 onItemChange
, this );
179 // Called when we have an interaction dialog to display
180 var_Create( pIntf
, "interaction", VLC_VAR_ADDRESS
);
181 var_AddCallback( pIntf
, "interaction", onInteraction
, this );
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",
207 onGenericCallback
, this );
208 var_DelCallback( getIntf()->p_libvlc
, "intf-toggle-fscontrol",
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 (void)pObj
; (void)pVariable
; (void)oldval
;
257 VlcProc
*pThis
= (VlcProc
*)pParam
;
258 input_thread_t
*pInput
= static_cast<input_thread_t
*>(newval
.p_address
);
260 var_AddCallback( pInput
, "intf-event", onGenericCallback2
, pThis
);
261 var_AddCallback( pInput
, "bit-rate", onGenericCallback
, pThis
);
262 var_AddCallback( pInput
, "sample-rate", onGenericCallback
, pThis
);
263 var_AddCallback( pInput
, "can-record", onGenericCallback
, pThis
);
269 int VlcProc::onItemChange( vlc_object_t
*pObj
, const char *pVariable
,
270 vlc_value_t oldval
, vlc_value_t newval
,
273 (void)pObj
; (void)pVariable
; (void)oldval
;
274 VlcProc
*pThis
= (VlcProc
*)pParam
;
275 input_item_t
*p_item
= static_cast<input_item_t
*>(newval
.p_address
);
277 // Create a playtree notify command
278 CmdPlaytreeUpdate
*pCmdTree
= new CmdPlaytreeUpdate( pThis
->getIntf(),
281 // Push the command in the asynchronous command queue
282 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
283 pQueue
->push( CmdGenericPtr( pCmdTree
), true );
288 int VlcProc::onItemAppend( vlc_object_t
*pObj
, const char *pVariable
,
289 vlc_value_t oldVal
, vlc_value_t newVal
,
292 (void)pObj
; (void)pVariable
; (void)oldVal
;
293 VlcProc
*pThis
= (VlcProc
*)pParam
;
295 playlist_add_t
*p_add
= static_cast<playlist_add_t
*>(newVal
.p_address
);
296 CmdPlaytreeAppend
*pCmdTree
=
297 new CmdPlaytreeAppend( pThis
->getIntf(), p_add
);
299 // Push the command in the asynchronous command queue
300 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
301 pQueue
->push( CmdGenericPtr( pCmdTree
), false );
306 int VlcProc::onItemDelete( vlc_object_t
*pObj
, const char *pVariable
,
307 vlc_value_t oldVal
, vlc_value_t newVal
,
310 (void)pObj
; (void)pVariable
; (void)oldVal
;
311 VlcProc
*pThis
= (VlcProc
*)pParam
;
313 int i_id
= newVal
.i_int
;
314 CmdPlaytreeDelete
*pCmdTree
=
315 new CmdPlaytreeDelete( pThis
->getIntf(), i_id
);
317 // Push the command in the asynchronous command queue
318 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
319 pQueue
->push( CmdGenericPtr( pCmdTree
), false );
324 int VlcProc::onInteraction( vlc_object_t
*pObj
, const char *pVariable
,
325 vlc_value_t oldVal
, vlc_value_t newVal
,
328 (void)pObj
; (void)pVariable
; (void)oldVal
;
329 VlcProc
*pThis
= (VlcProc
*)pParam
;
330 interaction_dialog_t
*p_dialog
= (interaction_dialog_t
*)(newVal
.p_address
);
332 CmdInteraction
*pCmd
= new CmdInteraction( pThis
->getIntf(), p_dialog
);
333 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
334 pQueue
->push( CmdGenericPtr( pCmd
) );
338 int VlcProc::onEqBandsChange( vlc_object_t
*pObj
, const char *pVariable
,
339 vlc_value_t oldVal
, vlc_value_t newVal
,
342 (void)pObj
; (void)pVariable
; (void)oldVal
;
343 VlcProc
*pThis
= (VlcProc
*)pParam
;
345 // Post a set equalizer bands command
346 CmdSetEqBands
*pCmd
= new CmdSetEqBands( pThis
->getIntf(),
349 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
350 pQueue
->push( CmdGenericPtr( pCmd
) );
356 int VlcProc::onEqPreampChange( vlc_object_t
*pObj
, const char *pVariable
,
357 vlc_value_t oldVal
, vlc_value_t newVal
,
360 (void)pObj
; (void)pVariable
; (void)oldVal
;
361 VlcProc
*pThis
= (VlcProc
*)pParam
;
362 EqualizerPreamp
*pVarPreamp
= (EqualizerPreamp
*)(pThis
->m_cVarEqPreamp
.get());
364 // Post a set preamp command
365 CmdSetEqPreamp
*pCmd
= new CmdSetEqPreamp( pThis
->getIntf(), *pVarPreamp
,
366 (newVal
.f_float
+ 20.0) / 40.0 );
367 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
368 pQueue
->push( CmdGenericPtr( pCmd
) );
374 int VlcProc::onGenericCallback( vlc_object_t
*pObj
, const char *pVariable
,
375 vlc_value_t oldVal
, vlc_value_t newVal
,
379 VlcProc
*pThis
= (VlcProc
*)pParam
;
380 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
382 #define ADD_CALLBACK_ENTRY( var, func, remove ) \
384 if( strcmp( pVariable, var ) == 0 ) \
386 string label = var; \
387 CmdGeneric *pCmd = new CmdCallback( pThis->getIntf(), pObj, newVal, \
388 &VlcProc::func, label ); \
390 pQueue->push( CmdGenericPtr( pCmd ), remove ); \
391 return VLC_SUCCESS; \
395 ADD_CALLBACK_ENTRY( "item-current", on_item_current_changed
, false )
396 ADD_CALLBACK_ENTRY( "volume", on_volume_changed
, true )
398 ADD_CALLBACK_ENTRY( "bit-rate", on_bit_rate_changed
, false )
399 ADD_CALLBACK_ENTRY( "sample-rate", on_sample_rate_changed
, false )
400 ADD_CALLBACK_ENTRY( "can-record", on_can_record_changed
, false )
402 ADD_CALLBACK_ENTRY( "random", on_random_changed
, false )
403 ADD_CALLBACK_ENTRY( "loop", on_loop_changed
, false )
404 ADD_CALLBACK_ENTRY( "repeat", on_repeat_changed
, false )
406 ADD_CALLBACK_ENTRY( "audio-filter", on_audio_filter_changed
, false )
408 ADD_CALLBACK_ENTRY( "intf-toggle-fscontrol", on_intf_show_changed
, false )
410 ADD_CALLBACK_ENTRY( "mouse-moved", on_mouse_moved_changed
, false )
412 #undef ADD_CALLBACK_ENTRY
414 msg_Err( pThis
->getIntf(), "no callback entry for %s", pVariable
);
419 int VlcProc::onGenericCallback2( vlc_object_t
*pObj
, const char *pVariable
,
420 vlc_value_t oldVal
, vlc_value_t newVal
,
424 VlcProc
*pThis
= (VlcProc
*)pParam
;
425 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
428 * For intf-event, commands are labeled based on the value of newVal.
430 * For some values (e.g position), only keep the latest command
431 * when there are multiple pending commands (remove=true).
433 * for others, don't discard commands (remove=false)
435 if( strcmp( pVariable
, "intf-event" ) == 0 )
439 switch( newVal
.i_int
)
441 case INPUT_EVENT_STATE
:
442 case INPUT_EVENT_POSITION
:
444 case INPUT_EVENT_CHAPTER
:
445 case INPUT_EVENT_RECORD
:
448 case INPUT_EVENT_VOUT
:
449 case INPUT_EVENT_AOUT
:
450 case INPUT_EVENT_DEAD
:
456 label
<< pVariable
<< "_" << newVal
.i_int
;
457 CmdGeneric
*pCmd
= new CmdCallback( pThis
->getIntf(), pObj
, newVal
,
458 &VlcProc::on_intf_event_changed
,
461 pQueue
->push( CmdGenericPtr( pCmd
), b_remove
);
466 msg_Err( pThis
->getIntf(), "no callback entry for %s", pVariable
);
471 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
472 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
473 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
474 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
475 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
477 void VlcProc::on_item_current_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
480 input_item_t
*p_item
= static_cast<input_item_t
*>(newVal
.p_address
);
483 char *psz_name
= input_item_GetName( p_item
);
484 SET_TEXT( m_cVarStreamName
, UString( getIntf(), psz_name
) );
487 // Update local path (if possible) or full uri
488 char *psz_uri
= input_item_GetURI( p_item
);
489 char *psz_path
= make_path( psz_uri
);
490 char *psz_save
= psz_path
? psz_path
: psz_uri
;
491 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), psz_save
) );
496 char *psz_art
= input_item_GetArtURL( p_item
);
497 SET_STRING( m_cVarStreamArt
, string( psz_art
? psz_art
: "" ) );
501 getPlaytreeVar().onUpdateCurrent( true );
504 void VlcProc::on_intf_event_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
506 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
508 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
510 if( !getIntf()->p_sys
->p_input
)
512 msg_Dbg( getIntf(), "new input %p detected", pInput
);
514 getIntf()->p_sys
->p_input
= pInput
;
515 vlc_object_hold( pInput
);
518 switch( newVal
.i_int
)
520 case INPUT_EVENT_STATE
:
522 int state
= var_GetInteger( pInput
, "state" );
523 SET_BOOL( m_cVarStopped
, false );
524 SET_BOOL( m_cVarPlaying
, state
!= PAUSE_S
);
525 SET_BOOL( m_cVarPaused
, state
== PAUSE_S
);
529 case INPUT_EVENT_POSITION
:
531 float pos
= var_GetFloat( pInput
, "position" );
532 SET_STREAMTIME( m_cVarTime
, pos
, false );
533 SET_BOOL( m_cVarSeekable
, pos
!= 0.0 );
540 vlc_value_t audio_es
;
541 var_Change( pInput
, "audio-es", VLC_VAR_CHOICESCOUNT
,
543 SET_BOOL( m_cVarHasAudio
, audio_es
.i_int
> 0 );
547 case INPUT_EVENT_VOUT
:
549 vout_thread_t
* pVout
= input_GetVout( pInput
);
550 SET_BOOL( m_cVarHasVout
, pVout
!= NULL
);
551 if( !pVout
|| pVout
== m_pVout
)
553 // end of input or vout reuse (nothing to do)
555 vlc_object_release( pVout
);
560 // remove previous Vout callbacks
561 var_DelCallback( m_pVout
, "mouse-moved",
562 onGenericCallback
, this );
563 vlc_object_release( m_pVout
);
567 // add new Vout callbackx
568 var_AddCallback( pVout
, "mouse-moved",
569 onGenericCallback
, this );
574 case INPUT_EVENT_AOUT
:
576 audio_output_t
* pAout
= input_GetAout( pInput
);
578 // end of input or aout reuse (nothing to do)
579 if( !pAout
|| pAout
== m_pAout
)
582 vlc_object_release( pAout
);
586 // remove previous Aout if any
589 var_DelCallback( m_pAout
, "audio-filter",
590 onGenericCallback
, this );
591 if( m_bEqualizer_started
)
593 var_DelCallback( m_pAout
, "equalizer-bands",
594 onEqBandsChange
, this );
595 var_DelCallback( m_pAout
, "equalizer-preamp",
596 onEqPreampChange
, this );
598 vlc_object_release( m_pAout
);
600 m_bEqualizer_started
= false;
603 // New Aout (addCallbacks)
604 var_AddCallback( pAout
, "audio-filter", onGenericCallback
, this );
606 char *pFilters
= var_GetNonEmptyString( pAout
, "audio-filter" );
607 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
609 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
612 var_AddCallback( pAout
, "equalizer-bands",
613 onEqBandsChange
, this );
614 var_AddCallback( pAout
, "equalizer-preamp",
615 onEqPreampChange
, this );
616 m_bEqualizer_started
= true;
622 case INPUT_EVENT_CHAPTER
:
624 vlc_value_t chapters_count
;
625 var_Change( pInput
, "chapter", VLC_VAR_CHOICESCOUNT
,
626 &chapters_count
, NULL
);
627 SET_BOOL( m_cVarDvdActive
, chapters_count
.i_int
> 0 );
631 case INPUT_EVENT_RECORD
:
632 SET_BOOL( m_cVarRecording
, var_GetBool( pInput
, "record" ) );
635 case INPUT_EVENT_DEAD
:
636 msg_Dbg( getIntf(), "end of input detected for %p", pInput
);
638 var_DelCallback( pInput
, "intf-event", onGenericCallback2
, this );
639 var_DelCallback( pInput
, "bit-rate", onGenericCallback
, this );
640 var_DelCallback( pInput
, "sample-rate", onGenericCallback
, this );
641 var_DelCallback( pInput
, "can-record" , onGenericCallback
, this );
642 vlc_object_release( pInput
);
643 getIntf()->p_sys
->p_input
= NULL
;
652 void VlcProc::on_bit_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
655 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
657 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
659 int bitrate
= var_GetInteger( pInput
, "bit-rate" ) / 1000;
660 SET_TEXT( m_cVarStreamBitRate
, UString::fromInt( getIntf(), bitrate
) );
663 void VlcProc::on_sample_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
666 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
668 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
670 int sampleRate
= var_GetInteger( pInput
, "sample-rate" ) / 1000;
671 SET_TEXT( m_cVarStreamSampleRate
, UString::fromInt(getIntf(),sampleRate
) );
674 void VlcProc::on_can_record_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
677 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
679 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
681 SET_BOOL( m_cVarRecordable
, var_GetBool( pInput
, "can-record" ) );
684 void VlcProc::on_random_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
687 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
689 SET_BOOL( m_cVarRandom
, var_GetBool( pPlaylist
, "random" ) );
692 void VlcProc::on_loop_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
695 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
697 SET_BOOL( m_cVarLoop
, var_GetBool( pPlaylist
, "loop" ) );
700 void VlcProc::on_repeat_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
703 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
705 SET_BOOL( m_cVarRepeat
, var_GetBool( pPlaylist
, "repeat" ) );
708 void VlcProc::on_volume_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
710 (void)p_obj
; (void)newVal
;
711 playlist_t
* pPlaylist
= getIntf()->p_sys
->p_playlist
;
713 audio_volume_t volume
= aout_VolumeGet( pPlaylist
);
714 SET_VOLUME( m_cVarVolume
, volume
, false );
715 SET_BOOL( m_cVarMute
, volume
== 0 );
718 void VlcProc::on_audio_filter_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
721 audio_output_t
* pAout
= (audio_output_t
*) p_obj
;
723 char *pFilters
= newVal
.psz_string
;
725 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
726 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
727 if( b_equalizer
&& !m_bEqualizer_started
)
729 var_AddCallback( pAout
, "equalizer-bands", onEqBandsChange
, this );
730 var_AddCallback( pAout
, "equalizer-preamp", onEqPreampChange
, this );
731 m_bEqualizer_started
= true;
735 void VlcProc::on_intf_show_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
737 (void)p_obj
; (void)newVal
;
738 bool b_fullscreen
= getFullscreenVar().get();
744 // Create a raise all command
745 CmdRaiseAll
*pCmd
= new CmdRaiseAll( getIntf(),
746 getIntf()->p_sys
->p_theme
->getWindowManager() );
748 // Push the command in the asynchronous command queue
749 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
750 pQueue
->push( CmdGenericPtr( pCmd
) );
755 VoutManager
* pVoutManager
= VoutManager::instance( getIntf() );
756 FscWindow
*pWin
= pVoutManager
->getFscWindow();
759 bool b_visible
= pWin
->getVisibleVar().get();
760 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
764 CmdShowWindow
* pCmd
= new CmdShowWindow( getIntf(),
765 getIntf()->p_sys
->p_theme
->getWindowManager(),
767 pQueue
->push( CmdGenericPtr( pCmd
) );
771 CmdHideWindow
* pCmd
= new CmdHideWindow( getIntf(),
772 getIntf()->p_sys
->p_theme
->getWindowManager(),
774 pQueue
->push( CmdGenericPtr( pCmd
) );
780 void VlcProc::on_mouse_moved_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
782 (void)p_obj
; (void)newVal
;
783 FscWindow
* pFscWindow
= VoutManager::instance( getIntf() )->getFscWindow();
785 pFscWindow
->onMouseMoved();
788 void VlcProc::reset_input()
790 SET_BOOL( m_cVarSeekable
, false );
791 SET_BOOL( m_cVarRecordable
, false );
792 SET_BOOL( m_cVarRecording
, false );
793 SET_BOOL( m_cVarDvdActive
, false );
794 SET_BOOL( m_cVarHasAudio
, false );
795 SET_BOOL( m_cVarHasVout
, false );
796 SET_BOOL( m_cVarStopped
, true );
797 SET_BOOL( m_cVarPlaying
, false );
798 SET_BOOL( m_cVarPaused
, false );
800 SET_STREAMTIME( m_cVarTime
, 0, false );
801 SET_TEXT( m_cVarStreamName
, UString( getIntf(), "") );
802 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), "") );
803 SET_TEXT( m_cVarStreamBitRate
, UString( getIntf(), "") );
804 SET_TEXT( m_cVarStreamSampleRate
, UString( getIntf(), "") );
806 getPlaytreeVar().onUpdateCurrent( false );
809 void VlcProc::init_variables()
811 playlist_t
* pPlaylist
= getIntf()->p_sys
->p_playlist
;
813 SET_BOOL( m_cVarRandom
, var_GetBool( pPlaylist
, "random" ) );
814 SET_BOOL( m_cVarLoop
, var_GetBool( pPlaylist
, "loop" ) );
815 SET_BOOL( m_cVarRepeat
, var_GetBool( pPlaylist
, "repeat" ) );
817 audio_volume_t volume
= aout_VolumeGet( pPlaylist
);
818 SET_VOLUME( m_cVarVolume
, volume
, false );
819 SET_BOOL( m_cVarMute
, volume
== 0 );
824 void VlcProc::update_equalizer()
829 pFilters
= var_GetNonEmptyString( m_pAout
, "audio-filter" );
831 pFilters
= var_InheritString( getIntf(), "audio-filter" );
833 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
836 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
839 void VlcProc::setFullscreenVar( bool b_fullscreen
)
841 SET_BOOL( m_cVarFullscreen
, b_fullscreen
);
845 #undef SET_STREAMTIME