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", onGenericCallback
, 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 CmdGeneric
*pCmd
= NULL
;
380 #define ADD_CALLBACK_ENTRY( var, label ) \
382 if( strcmp( pVariable, var ) == 0 ) \
383 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
386 ADD_CALLBACK_ENTRY( "item-current", item_current_changed
)
387 ADD_CALLBACK_ENTRY( "volume-change", volume_changed
)
389 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed
)
390 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed
)
391 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed
)
392 ADD_CALLBACK_ENTRY( "can-record", can_record_changed
)
394 ADD_CALLBACK_ENTRY( "random", random_changed
)
395 ADD_CALLBACK_ENTRY( "loop", loop_changed
)
396 ADD_CALLBACK_ENTRY( "repeat", repeat_changed
)
398 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed
)
400 ADD_CALLBACK_ENTRY( "intf-show", intf_show_changed
)
402 #undef ADD_CALLBACK_ENTRY
405 pQueue
->push( CmdGenericPtr( pCmd
), false );
407 msg_Err( pObj
, "no Callback entry provided for %s", pVariable
);
412 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
413 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
414 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
415 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
416 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
418 void VlcProc::on_item_current_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
420 input_item_t
*p_item
= static_cast<input_item_t
*>(newVal
.p_address
);
423 char *psz_name
= input_item_GetName( p_item
);
424 SET_TEXT( m_cVarStreamName
, UString( getIntf(), psz_name
) );
428 char *psz_uri
= input_item_GetURI( p_item
);
429 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), psz_uri
) );
433 char *psz_art
= input_item_GetArtURL( p_item
);
434 SET_STRING( m_cVarStreamArt
, string( psz_art
? psz_art
: "" ) );
438 getPlaytreeVar().onUpdateCurrent( true );
441 void VlcProc::on_intf_event_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
443 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
445 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
447 if( !getIntf()->p_sys
->p_input
)
449 msg_Dbg( getIntf(), "new input %p detected", pInput
);
451 getIntf()->p_sys
->p_input
= pInput
;
452 vlc_object_hold( pInput
);
455 switch( newVal
.i_int
)
457 case INPUT_EVENT_STATE
:
459 int state
= var_GetInteger( pInput
, "state" );
460 SET_BOOL( m_cVarStopped
, false );
461 SET_BOOL( m_cVarPlaying
, state
!= PAUSE_S
);
462 SET_BOOL( m_cVarPaused
, state
== PAUSE_S
);
466 case INPUT_EVENT_POSITION
:
468 float pos
= var_GetFloat( pInput
, "position" );
469 SET_STREAMTIME( m_cVarTime
, pos
, false );
470 SET_BOOL( m_cVarSeekable
, pos
!= 0.0 );
477 vlc_value_t audio_es
;
478 var_Change( pInput
, "audio-es", VLC_VAR_CHOICESCOUNT
,
480 SET_BOOL( m_cVarHasAudio
, audio_es
.i_int
> 0 );
484 case INPUT_EVENT_VOUT
:
486 vout_thread_t
* pVout
= input_GetVout( pInput
);
487 SET_BOOL( m_cVarHasVout
, pVout
!= NULL
);
490 SET_BOOL( m_cVarFullscreen
,
491 var_GetBool( pVout
, "fullscreen" ) );
492 vlc_object_release( pVout
);
497 case INPUT_EVENT_AOUT
:
499 aout_instance_t
* pAout
= input_GetAout( pInput
);
501 // end of input or aout reuse (nothing to do)
502 if( !pAout
|| pAout
== m_pAout
)
505 vlc_object_release( pAout
);
509 // remove previous Aout if any
512 var_DelCallback( m_pAout
, "audio-filter",
513 onGenericCallback
, this );
514 if( m_bEqualizer_started
)
516 var_DelCallback( m_pAout
, "equalizer-bands",
517 onEqBandsChange
, this );
518 var_DelCallback( m_pAout
, "equalizer-preamp",
519 onEqPreampChange
, this );
521 vlc_object_release( m_pAout
);
523 m_bEqualizer_started
= false;
526 // New Aout (addCallbacks)
527 var_AddCallback( pAout
, "audio-filter", onGenericCallback
, this );
529 char *pFilters
= var_GetNonEmptyString( pAout
, "audio-filter" );
530 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
532 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
535 var_AddCallback( pAout
, "equalizer-bands",
536 onEqBandsChange
, this );
537 var_AddCallback( pAout
, "equalizer-preamp",
538 onEqPreampChange
, this );
539 m_bEqualizer_started
= true;
545 case INPUT_EVENT_CHAPTER
:
547 vlc_value_t chapters_count
;
548 var_Change( pInput
, "chapter", VLC_VAR_CHOICESCOUNT
,
549 &chapters_count
, NULL
);
550 SET_BOOL( m_cVarDvdActive
, chapters_count
.i_int
> 0 );
554 case INPUT_EVENT_RECORD
:
555 SET_BOOL( m_cVarRecording
, var_GetBool( pInput
, "record" ) );
558 case INPUT_EVENT_DEAD
:
559 msg_Dbg( getIntf(), "end of input detected for %p", pInput
);
561 var_DelCallback( pInput
, "intf-event", onGenericCallback
, this );
562 var_DelCallback( pInput
, "bit-rate", onGenericCallback
, this );
563 var_DelCallback( pInput
, "sample-rate", onGenericCallback
, this );
564 var_DelCallback( pInput
, "can-record" , onGenericCallback
, this );
565 vlc_object_release( pInput
);
566 getIntf()->p_sys
->p_input
= NULL
;
575 void VlcProc::on_bit_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
577 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
579 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
581 int bitrate
= var_GetInteger( pInput
, "bit-rate" ) / 1000;
582 SET_TEXT( m_cVarStreamBitRate
, UString::fromInt( getIntf(), bitrate
) );
585 void VlcProc::on_sample_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
587 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
589 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
591 int sampleRate
= var_GetInteger( pInput
, "sample-rate" ) / 1000;
592 SET_TEXT( m_cVarStreamSampleRate
, UString::fromInt(getIntf(),sampleRate
) );
595 void VlcProc::on_can_record_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
597 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
599 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
601 SET_BOOL( m_cVarRecordable
, var_GetBool( pInput
, "can-record" ) );
604 void VlcProc::on_random_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
606 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
608 SET_BOOL( m_cVarRandom
, var_GetBool( pPlaylist
, "random" ) );
611 void VlcProc::on_loop_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
613 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
615 SET_BOOL( m_cVarLoop
, var_GetBool( pPlaylist
, "loop" ) );
618 void VlcProc::on_repeat_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
620 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
622 SET_BOOL( m_cVarRepeat
, var_GetBool( pPlaylist
, "repeat" ) );
625 void VlcProc::on_volume_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
627 (void)p_obj
; (void)newVal
;
628 playlist_t
* pPlaylist
= getIntf()->p_sys
->p_playlist
;
630 audio_volume_t volume
;
631 aout_VolumeGet( pPlaylist
, &volume
);
632 SET_VOLUME( m_cVarVolume
, (double)volume
/ AOUT_VOLUME_MAX
, false );
633 SET_BOOL( m_cVarMute
, volume
== 0 );
636 void VlcProc::on_audio_filter_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
638 aout_instance_t
* pAout
= (aout_instance_t
*) p_obj
;
640 char *pFilters
= newVal
.psz_string
;
642 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
643 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
644 if( b_equalizer
&& !m_bEqualizer_started
)
646 var_AddCallback( pAout
, "equalizer-bands", onEqBandsChange
, this );
647 var_AddCallback( pAout
, "equalizer-preamp", onEqPreampChange
, this );
648 m_bEqualizer_started
= true;
652 void VlcProc::on_intf_show_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
655 bool b_fullscreen
= getFullscreenVar().get();
661 // Create a raise all command
662 CmdRaiseAll
*pCmd
= new CmdRaiseAll( getIntf(),
663 getIntf()->p_sys
->p_theme
->getWindowManager() );
665 // Push the command in the asynchronous command queue
666 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
667 pQueue
->push( CmdGenericPtr( pCmd
) );
672 Theme
* pTheme
= getIntf()->p_sys
->p_theme
;
673 TopWindow
*pWin
= pTheme
->getWindowById( "fullscreenController" );
676 bool b_visible
= pWin
->getVisibleVar().get();
677 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
681 CmdShowWindow
* pCmd
= new CmdShowWindow( getIntf(),
682 getIntf()->p_sys
->p_theme
->getWindowManager(),
684 pQueue
->push( CmdGenericPtr( pCmd
) );
688 CmdHideWindow
* pCmd
= new CmdHideWindow( getIntf(),
689 getIntf()->p_sys
->p_theme
->getWindowManager(),
691 pQueue
->push( CmdGenericPtr( pCmd
) );
697 void VlcProc::reset_input()
699 SET_BOOL( m_cVarSeekable
, false );
700 SET_BOOL( m_cVarRecordable
, false );
701 SET_BOOL( m_cVarRecording
, false );
702 SET_BOOL( m_cVarDvdActive
, false );
703 SET_BOOL( m_cVarFullscreen
, false );
704 SET_BOOL( m_cVarHasAudio
, false );
705 SET_BOOL( m_cVarHasVout
, false );
706 SET_BOOL( m_cVarStopped
, true );
707 SET_BOOL( m_cVarPlaying
, false );
708 SET_BOOL( m_cVarPaused
, false );
710 SET_STREAMTIME( m_cVarTime
, 0, false );
711 SET_TEXT( m_cVarStreamName
, UString( getIntf(), "") );
712 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), "") );
713 SET_TEXT( m_cVarStreamBitRate
, UString( getIntf(), "") );
714 SET_TEXT( m_cVarStreamSampleRate
, UString( getIntf(), "") );
716 getPlaytreeVar().onUpdateCurrent( false );
719 void VlcProc::init_variables()
721 playlist_t
* pPlaylist
= getIntf()->p_sys
->p_playlist
;
723 SET_BOOL( m_cVarRandom
, var_GetBool( pPlaylist
, "random" ) );
724 SET_BOOL( m_cVarLoop
, var_GetBool( pPlaylist
, "loop" ) );
725 SET_BOOL( m_cVarRepeat
, var_GetBool( pPlaylist
, "repeat" ) );
727 audio_volume_t volume
;
728 aout_VolumeGet( pPlaylist
, &volume
);
729 SET_VOLUME( m_cVarVolume
, (double)volume
/ AOUT_VOLUME_MAX
, false );
730 SET_BOOL( m_cVarMute
, volume
== 0 );
735 void VlcProc::update_equalizer()
740 pFilters
= var_GetNonEmptyString( m_pAout
, "audio-filter" );
742 pFilters
= var_InheritString( getIntf(), "audio-filter" );
744 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
747 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
750 void VlcProc::setFullscreenVar( bool b_fullscreen
)
752 SET_BOOL( m_cVarFullscreen
, b_fullscreen
);
756 #undef SET_STREAMTIME