skins2: implement art display in image controls
[vlc/asuraparaju-public.git] / modules / gui / skins2 / src / vlcproc.cpp
blobaf82e1f114121046a8e08837328de6adf19727bd
1 /*****************************************************************************
2 * vlcproc.cpp
3 *****************************************************************************
4 * Copyright (C) 2003-2009 the VideoLAN team
5 * $Id$
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 *****************************************************************************/
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
30 #include <vlc_common.h>
31 #include <vlc_aout.h>
32 #include <vlc_vout.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"
41 #include "theme.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"
54 #include <sstream>
56 #include <assert.h>
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(),
96 "playtree.slider" );
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" )
113 /* Vout variables */
114 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
115 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
117 /* Aout variables */
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" )
124 #undef REGISTER_VAR
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++)
139 stringstream ss;
140 ss << "equalizer.band(" << i << ")";
141 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
144 // XXX WARNING XXX
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" )
160 #undef ADD_CALLBACK
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",
171 onInputNew, this );
172 // Called when a playlist item changed
173 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
174 onItemChange, this );
175 // Called when our skins2 demux wants us to load a new skin
176 var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, 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
184 init_variables();
188 VlcProc::~VlcProc()
190 m_pTimer->stop();
191 delete( m_pTimer );
193 if( m_pAout )
195 vlc_object_release( m_pAout );
196 m_pAout = NULL;
198 if( m_pVout )
200 vlc_object_release( m_pVout );
201 m_pVout = NULL;
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",
225 onInputNew, this );
226 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
227 onItemChange, this );
228 var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
229 var_DelCallback( getIntf(), "interaction", onInteraction, this );
232 void VlcProc::manage()
234 // Did the user request to quit vlc ?
235 if( !vlc_object_alive( getIntf() ) )
237 // Get the instance of OSFactory
238 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
240 // Exit the main OS loop
241 pOsFactory->getOSLoop()->exit();
243 return;
247 void VlcProc::CmdManage::execute()
249 // Just forward to VlcProc
250 m_pParent->manage();
254 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
255 vlc_value_t oldval, vlc_value_t newval, void *pParam )
257 VlcProc *pThis = (VlcProc*)pParam;
258 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
260 var_AddCallback( pInput, "intf-event", onGenericCallback, 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 );
265 return VLC_SUCCESS;
269 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
270 vlc_value_t oldval, vlc_value_t newval,
271 void *pParam )
273 VlcProc *pThis = (VlcProc*)pParam;
274 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
276 // Create a playtree notify command
277 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
278 p_item );
280 // Push the command in the asynchronous command queue
281 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
282 pQueue->push( CmdGenericPtr( pCmdTree ), true );
284 return VLC_SUCCESS;
287 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
288 vlc_value_t oldVal, vlc_value_t newVal,
289 void *pParam )
291 VlcProc *pThis = (VlcProc*)pParam;
293 playlist_add_t *p_add = static_cast<playlist_add_t*>(newVal.p_address);
295 CmdGenericPtr ptrTree;
296 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
297 p_add );
298 ptrTree = CmdGenericPtr( pCmdTree );
300 // Push the command in the asynchronous command queue
301 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
302 pQueue->push( ptrTree , false );
304 return VLC_SUCCESS;
307 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
308 vlc_value_t oldVal, vlc_value_t newVal,
309 void *pParam )
311 VlcProc *pThis = (VlcProc*)pParam;
313 int i_id = newVal.i_int;
315 CmdGenericPtr ptrTree;
316 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
317 i_id);
318 ptrTree = CmdGenericPtr( pCmdTree );
320 // Push the command in the asynchronous command queue
321 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
322 pQueue->push( ptrTree , false );
324 return VLC_SUCCESS;
328 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
329 vlc_value_t oldVal, vlc_value_t newVal,
330 void *pParam )
332 VlcProc *pThis = (VlcProc*)pParam;
334 // Create a playlist notify command
335 CmdChangeSkin *pCmd =
336 new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
338 // Push the command in the asynchronous command queue
339 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
340 pQueue->push( CmdGenericPtr( pCmd ) );
342 return VLC_SUCCESS;
345 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
346 vlc_value_t oldVal, vlc_value_t newVal,
347 void *pParam )
349 VlcProc *pThis = (VlcProc*)pParam;
350 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
352 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
353 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
354 pQueue->push( CmdGenericPtr( pCmd ) );
355 return VLC_SUCCESS;
358 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
359 vlc_value_t oldVal, vlc_value_t newVal,
360 void *pParam )
362 VlcProc *pThis = (VlcProc*)pParam;
364 // Post a set equalizer bands command
365 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
366 pThis->m_varEqBands,
367 newVal.psz_string );
368 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
369 pQueue->push( CmdGenericPtr( pCmd ) );
371 return VLC_SUCCESS;
375 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
376 vlc_value_t oldVal, vlc_value_t newVal,
377 void *pParam )
379 VlcProc *pThis = (VlcProc*)pParam;
380 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
382 // Post a set preamp command
383 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
384 (newVal.f_float + 20.0) / 40.0 );
385 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
386 pQueue->push( CmdGenericPtr( pCmd ) );
388 return VLC_SUCCESS;
392 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
393 vlc_value_t oldVal, vlc_value_t newVal,
394 void *pParam )
396 VlcProc *pThis = (VlcProc*)pParam;
397 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
399 CmdGeneric *pCmd = NULL;
401 #define ADD_CALLBACK_ENTRY( var, label ) \
403 if( strcmp( pVariable, var ) == 0 ) \
404 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
407 ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
408 ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
410 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
411 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
412 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
413 ADD_CALLBACK_ENTRY( "can-record", can_record_changed )
415 ADD_CALLBACK_ENTRY( "random", random_changed )
416 ADD_CALLBACK_ENTRY( "loop", loop_changed )
417 ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
419 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
421 ADD_CALLBACK_ENTRY( "intf-show", intf_show_changed )
423 #undef ADD_CALLBACK_ENTRY
425 if( pCmd )
426 pQueue->push( CmdGenericPtr( pCmd ), false );
427 else
428 msg_Err( pObj, "no Callback entry provided for %s", pVariable );
430 return VLC_SUCCESS;
433 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
434 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
435 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
436 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
437 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
439 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
441 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
443 // Update short name
444 char *psz_name = input_item_GetName( p_item );
445 SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
446 free( psz_name );
448 // Update full uri
449 char *psz_uri = input_item_GetURI( p_item );
450 SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_uri ) );
451 free( psz_uri );
453 // Update art uri
454 char *psz_art = input_item_GetArtURL( p_item );
455 SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
456 free( psz_art );
458 // Update playtree
459 getPlaytreeVar().onUpdateCurrent( true );
462 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
464 input_thread_t* pInput = (input_thread_t*) p_obj;
466 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
468 if( !getIntf()->p_sys->p_input )
470 msg_Dbg( getIntf(), "new input %p detected", pInput );
472 getIntf()->p_sys->p_input = pInput;
473 vlc_object_hold( pInput );
476 switch( newVal.i_int )
478 case INPUT_EVENT_STATE:
480 int state = var_GetInteger( pInput, "state" );
481 SET_BOOL( m_cVarStopped, false );
482 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
483 SET_BOOL( m_cVarPaused, state == PAUSE_S );
484 break;
487 case INPUT_EVENT_POSITION:
489 float pos = var_GetFloat( pInput, "position" );
490 SET_STREAMTIME( m_cVarTime, pos, false );
491 SET_BOOL( m_cVarSeekable, pos != 0.0 );
492 break;
495 case INPUT_EVENT_ES:
497 // Do we have audio
498 vlc_value_t audio_es;
499 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
500 &audio_es, NULL );
501 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
502 break;
505 case INPUT_EVENT_VOUT:
507 vout_thread_t* pVout = input_GetVout( pInput );
508 SET_BOOL( m_cVarHasVout, pVout != NULL );
509 if( pVout )
511 SET_BOOL( m_cVarFullscreen,
512 var_GetBool( pVout, "fullscreen" ) );
513 vlc_object_release( pVout );
515 break;
518 case INPUT_EVENT_AOUT:
520 aout_instance_t* pAout = input_GetAout( pInput );
522 // end of input or aout reuse (nothing to do)
523 if( !pAout || pAout == m_pAout )
525 if( pAout )
526 vlc_object_release( pAout );
527 break;
530 // remove previous Aout if any
531 if( m_pAout )
533 var_DelCallback( m_pAout, "audio-filter",
534 onGenericCallback, this );
535 if( m_bEqualizer_started )
537 var_DelCallback( m_pAout, "equalizer-bands",
538 onEqBandsChange, this );
539 var_DelCallback( m_pAout, "equalizer-preamp",
540 onEqPreampChange, this );
542 vlc_object_release( m_pAout );
543 m_pAout = NULL;
544 m_bEqualizer_started = false;
547 // New Aout (addCallbacks)
548 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
550 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
551 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
552 free( pFilters );
553 SET_BOOL( m_cVarEqualizer, b_equalizer );
554 if( b_equalizer )
556 var_AddCallback( pAout, "equalizer-bands",
557 onEqBandsChange, this );
558 var_AddCallback( pAout, "equalizer-preamp",
559 onEqPreampChange, this );
560 m_bEqualizer_started = true;
562 m_pAout = pAout;
563 break;
566 case INPUT_EVENT_CHAPTER:
568 vlc_value_t chapters_count;
569 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
570 &chapters_count, NULL );
571 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
572 break;
575 case INPUT_EVENT_RECORD:
576 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
577 break;
579 case INPUT_EVENT_DEAD:
580 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
582 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
583 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
584 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
585 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
586 vlc_object_release( pInput );
587 getIntf()->p_sys->p_input = NULL;
588 reset_input();
589 break;
591 default:
592 break;
596 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
598 input_thread_t* pInput = (input_thread_t*) p_obj;
600 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
602 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
603 SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
606 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
608 input_thread_t* pInput = (input_thread_t*) p_obj;
610 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
612 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
613 SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
616 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
618 input_thread_t* pInput = (input_thread_t*) p_obj;
620 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
622 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
625 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
627 playlist_t* pPlaylist = (playlist_t*) p_obj;
629 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
632 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
634 playlist_t* pPlaylist = (playlist_t*) p_obj;
636 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
639 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
641 playlist_t* pPlaylist = (playlist_t*) p_obj;
643 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
646 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
648 (void)p_obj; (void)newVal;
649 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
651 audio_volume_t volume;
652 aout_VolumeGet( pPlaylist, &volume );
653 SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
654 SET_BOOL( m_cVarMute, volume == 0 );
657 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
659 aout_instance_t* pAout = (aout_instance_t*) p_obj;
661 char *pFilters = newVal.psz_string;
663 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
664 SET_BOOL( m_cVarEqualizer, b_equalizer );
665 if( b_equalizer && !m_bEqualizer_started )
667 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
668 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
669 m_bEqualizer_started = true;
673 void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
675 (void)p_obj;
676 bool b_fullscreen = getFullscreenVar().get();
678 if( !b_fullscreen )
680 if( newVal.b_bool )
682 // Create a raise all command
683 CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
684 getIntf()->p_sys->p_theme->getWindowManager() );
686 // Push the command in the asynchronous command queue
687 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
688 pQueue->push( CmdGenericPtr( pCmd ) );
691 else
693 Theme* pTheme = getIntf()->p_sys->p_theme;
694 TopWindow *pWin = pTheme->getWindowById( "fullscreenController" );
695 if( pWin )
697 bool b_visible = pWin->getVisibleVar().get();
698 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
700 if( !b_visible )
702 CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
703 getIntf()->p_sys->p_theme->getWindowManager(),
704 *pWin );
705 pQueue->push( CmdGenericPtr( pCmd ) );
707 else
709 CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
710 getIntf()->p_sys->p_theme->getWindowManager(),
711 *pWin );
712 pQueue->push( CmdGenericPtr( pCmd ) );
718 void VlcProc::reset_input()
720 SET_BOOL( m_cVarSeekable, false );
721 SET_BOOL( m_cVarRecordable, false );
722 SET_BOOL( m_cVarRecording, false );
723 SET_BOOL( m_cVarDvdActive, false );
724 SET_BOOL( m_cVarFullscreen, false );
725 SET_BOOL( m_cVarHasAudio, false );
726 SET_BOOL( m_cVarHasVout, false );
727 SET_BOOL( m_cVarStopped, true );
728 SET_BOOL( m_cVarPlaying, false );
729 SET_BOOL( m_cVarPaused, false );
731 SET_STREAMTIME( m_cVarTime, 0, false );
732 SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
733 SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
734 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
735 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
737 getPlaytreeVar().onUpdateCurrent( false );
740 void VlcProc::init_variables()
742 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
744 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
745 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
746 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
748 audio_volume_t volume;
749 aout_VolumeGet( pPlaylist, &volume );
750 SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
751 SET_BOOL( m_cVarMute, volume == 0 );
753 update_equalizer();
756 void VlcProc::update_equalizer()
759 char *pFilters;
760 if( m_pAout )
761 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
762 else
763 pFilters = var_InheritString( getIntf(), "audio-filter" );
765 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
766 free( pFilters );
768 SET_BOOL( m_cVarEqualizer, b_equalizer );
771 void VlcProc::setFullscreenVar( bool b_fullscreen )
773 SET_BOOL( m_cVarFullscreen, b_fullscreen );
776 #undef SET_BOOL
777 #undef SET_STREAMTIME
778 #undef SET_TEXT
779 #undef SET_STRING
780 #undef SET_VOLUME