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
);
489 vlc_object_release( pVout
);
493 case INPUT_EVENT_AOUT
:
495 aout_instance_t
* pAout
= input_GetAout( pInput
);
497 // end of input or aout reuse (nothing to do)
498 if( !pAout
|| pAout
== m_pAout
)
501 vlc_object_release( pAout
);
505 // remove previous Aout if any
508 var_DelCallback( m_pAout
, "audio-filter",
509 onGenericCallback
, this );
510 if( m_bEqualizer_started
)
512 var_DelCallback( m_pAout
, "equalizer-bands",
513 onEqBandsChange
, this );
514 var_DelCallback( m_pAout
, "equalizer-preamp",
515 onEqPreampChange
, this );
517 vlc_object_release( m_pAout
);
519 m_bEqualizer_started
= false;
522 // New Aout (addCallbacks)
523 var_AddCallback( pAout
, "audio-filter", onGenericCallback
, this );
525 char *pFilters
= var_GetNonEmptyString( pAout
, "audio-filter" );
526 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
528 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
531 var_AddCallback( pAout
, "equalizer-bands",
532 onEqBandsChange
, this );
533 var_AddCallback( pAout
, "equalizer-preamp",
534 onEqPreampChange
, this );
535 m_bEqualizer_started
= true;
541 case INPUT_EVENT_CHAPTER
:
543 vlc_value_t chapters_count
;
544 var_Change( pInput
, "chapter", VLC_VAR_CHOICESCOUNT
,
545 &chapters_count
, NULL
);
546 SET_BOOL( m_cVarDvdActive
, chapters_count
.i_int
> 0 );
550 case INPUT_EVENT_RECORD
:
551 SET_BOOL( m_cVarRecording
, var_GetBool( pInput
, "record" ) );
554 case INPUT_EVENT_DEAD
:
555 msg_Dbg( getIntf(), "end of input detected for %p", pInput
);
557 var_DelCallback( pInput
, "intf-event", onGenericCallback
, this );
558 var_DelCallback( pInput
, "bit-rate", onGenericCallback
, this );
559 var_DelCallback( pInput
, "sample-rate", onGenericCallback
, this );
560 var_DelCallback( pInput
, "can-record" , onGenericCallback
, this );
561 vlc_object_release( pInput
);
562 getIntf()->p_sys
->p_input
= NULL
;
571 void VlcProc::on_bit_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
573 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
575 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
577 int bitrate
= var_GetInteger( pInput
, "bit-rate" ) / 1000;
578 SET_TEXT( m_cVarStreamBitRate
, UString::fromInt( getIntf(), bitrate
) );
581 void VlcProc::on_sample_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
583 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
585 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
587 int sampleRate
= var_GetInteger( pInput
, "sample-rate" ) / 1000;
588 SET_TEXT( m_cVarStreamSampleRate
, UString::fromInt(getIntf(),sampleRate
) );
591 void VlcProc::on_can_record_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
593 input_thread_t
* pInput
= (input_thread_t
*) p_obj
;
595 assert( getIntf()->p_sys
->p_input
== NULL
|| getIntf()->p_sys
->p_input
== pInput
);
597 SET_BOOL( m_cVarRecordable
, var_GetBool( pInput
, "can-record" ) );
600 void VlcProc::on_random_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
602 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
604 SET_BOOL( m_cVarRandom
, var_GetBool( pPlaylist
, "random" ) );
607 void VlcProc::on_loop_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
609 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
611 SET_BOOL( m_cVarLoop
, var_GetBool( pPlaylist
, "loop" ) );
614 void VlcProc::on_repeat_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
616 playlist_t
* pPlaylist
= (playlist_t
*) p_obj
;
618 SET_BOOL( m_cVarRepeat
, var_GetBool( pPlaylist
, "repeat" ) );
621 void VlcProc::on_volume_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
623 (void)p_obj
; (void)newVal
;
624 playlist_t
* pPlaylist
= getIntf()->p_sys
->p_playlist
;
626 audio_volume_t volume
;
627 aout_VolumeGet( pPlaylist
, &volume
);
628 SET_VOLUME( m_cVarVolume
, (double)volume
/ AOUT_VOLUME_MAX
, false );
629 SET_BOOL( m_cVarMute
, volume
== 0 );
632 void VlcProc::on_audio_filter_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
634 aout_instance_t
* pAout
= (aout_instance_t
*) p_obj
;
636 char *pFilters
= newVal
.psz_string
;
638 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
639 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
640 if( b_equalizer
&& !m_bEqualizer_started
)
642 var_AddCallback( pAout
, "equalizer-bands", onEqBandsChange
, this );
643 var_AddCallback( pAout
, "equalizer-preamp", onEqPreampChange
, this );
644 m_bEqualizer_started
= true;
648 void VlcProc::on_intf_show_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
)
651 bool b_fullscreen
= getFullscreenVar().get();
657 // Create a raise all command
658 CmdRaiseAll
*pCmd
= new CmdRaiseAll( getIntf(),
659 getIntf()->p_sys
->p_theme
->getWindowManager() );
661 // Push the command in the asynchronous command queue
662 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
663 pQueue
->push( CmdGenericPtr( pCmd
) );
668 Theme
* pTheme
= getIntf()->p_sys
->p_theme
;
669 TopWindow
*pWin
= pTheme
->getWindowById( "fullscreenController" );
672 bool b_visible
= pWin
->getVisibleVar().get();
673 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
677 CmdShowWindow
* pCmd
= new CmdShowWindow( getIntf(),
678 getIntf()->p_sys
->p_theme
->getWindowManager(),
680 pQueue
->push( CmdGenericPtr( pCmd
) );
684 CmdHideWindow
* pCmd
= new CmdHideWindow( getIntf(),
685 getIntf()->p_sys
->p_theme
->getWindowManager(),
687 pQueue
->push( CmdGenericPtr( pCmd
) );
693 void VlcProc::reset_input()
695 SET_BOOL( m_cVarSeekable
, false );
696 SET_BOOL( m_cVarRecordable
, false );
697 SET_BOOL( m_cVarRecording
, false );
698 SET_BOOL( m_cVarDvdActive
, false );
699 SET_BOOL( m_cVarHasAudio
, false );
700 SET_BOOL( m_cVarHasVout
, false );
701 SET_BOOL( m_cVarStopped
, true );
702 SET_BOOL( m_cVarPlaying
, false );
703 SET_BOOL( m_cVarPaused
, false );
705 SET_STREAMTIME( m_cVarTime
, 0, false );
706 SET_TEXT( m_cVarStreamName
, UString( getIntf(), "") );
707 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), "") );
708 SET_TEXT( m_cVarStreamBitRate
, UString( getIntf(), "") );
709 SET_TEXT( m_cVarStreamSampleRate
, UString( getIntf(), "") );
711 getPlaytreeVar().onUpdateCurrent( false );
714 void VlcProc::init_variables()
716 playlist_t
* pPlaylist
= getIntf()->p_sys
->p_playlist
;
718 SET_BOOL( m_cVarRandom
, var_GetBool( pPlaylist
, "random" ) );
719 SET_BOOL( m_cVarLoop
, var_GetBool( pPlaylist
, "loop" ) );
720 SET_BOOL( m_cVarRepeat
, var_GetBool( pPlaylist
, "repeat" ) );
722 audio_volume_t volume
;
723 aout_VolumeGet( pPlaylist
, &volume
);
724 SET_VOLUME( m_cVarVolume
, (double)volume
/ AOUT_VOLUME_MAX
, false );
725 SET_BOOL( m_cVarMute
, volume
== 0 );
730 void VlcProc::update_equalizer()
735 pFilters
= var_GetNonEmptyString( m_pAout
, "audio-filter" );
737 pFilters
= var_InheritString( getIntf(), "audio-filter" );
739 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
742 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
745 void VlcProc::setFullscreenVar( bool b_fullscreen
)
747 SET_BOOL( m_cVarFullscreen
, b_fullscreen
);
751 #undef SET_STREAMTIME