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
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 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_update_item.hpp"
51 #include "../commands/cmd_audio.hpp"
52 #include "../commands/cmd_callbacks.hpp"
53 #include "../utils/var_bool.hpp"
57 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
59 if( pIntf->p_sys->p_vlcProc == NULL )
61 pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
64 return pIntf->p_sys->p_vlcProc;
68 void VlcProc::destroy( intf_thread_t *pIntf )
70 delete pIntf->p_sys->p_vlcProc;
71 pIntf->p_sys->p_vlcProc = NULL;
75 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
76 m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
77 m_pVout( NULL ), m_pAout( NULL ), m_bEqualizer_started( false ),
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" );
134 // Register the equalizer bands
135 for( int i = 0; i < EqualizerBands::kNbBands; i++)
138 ss << "equalizer.band(" << i << ")";
139 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
143 // The object variable callbacks are called from other VLC threads,
144 // so they must put commands in the queue and NOT do anything else
145 // (X11 calls are not reentrant)
147 // Called when volume sound changes
148 #define ADD_CALLBACK( p_object, var ) \
149 var_AddCallback( p_object, var, onGenericCallback, this );
151 ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
153 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
154 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
155 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
156 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
160 // Called when the playlist changes
161 var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
162 onIntfChange, this );
163 // Called when a playlist item is added
164 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
165 onItemAppend, this );
166 // Called when a playlist item is deleted
167 // TODO: properly handle item-deleted
168 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
169 onItemDelete, this );
170 // Called when the "interface shower" wants us to show the skin
171 var_AddCallback( pIntf->p_libvlc, "intf-show",
173 // Called when the current input changes
174 var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
176 // Called when a playlist item changed
177 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
178 onItemChange, this );
179 // Called when our skins2 demux wants us to load a new skin
180 var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
182 // Called when we have an interaction dialog to display
183 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
184 var_AddCallback( pIntf, "interaction", onInteraction, this );
185 interaction_Register( pIntf );
187 // initialize variables refering to liblvc and playlist objects
199 vlc_object_release( m_pAout );
204 vlc_object_release( m_pVout );
208 if( getIntf()->p_sys->p_input )
211 interaction_Unregister( getIntf() );
213 var_DelCallback( getIntf()->p_libvlc, "volume-change",
214 onGenericCallback, this );
216 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
217 onGenericCallback, this );
218 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
219 onGenericCallback, this );
220 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
221 onGenericCallback, this );
222 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
223 onGenericCallback, this );
224 var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
225 onIntfChange, this );
226 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
227 onItemAppend, this );
228 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
229 onItemDelete, this );
230 var_DelCallback( getIntf()->p_libvlc, "intf-show",
232 var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
234 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
235 onItemChange, this );
236 var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
237 var_DelCallback( getIntf(), "interaction", onInteraction, this );
240 void VlcProc::manage()
242 // Did the user request to quit vlc ?
243 if( !vlc_object_alive( getIntf() ) )
245 // Get the instance of OSFactory
246 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
248 // Exit the main OS loop
249 pOsFactory->getOSLoop()->exit();
255 void VlcProc::CmdManage::execute()
257 // Just forward to VlcProc
262 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
263 vlc_value_t oldVal, vlc_value_t newVal,
266 VlcProc *pThis = (VlcProc*)pParam;
268 // Update the stream variable
269 pThis->updateStreamName();
271 // Create a playtree notify command (for new style playtree)
272 CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
274 // Push the command in the asynchronous command queue
275 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
276 pQueue->push( CmdGenericPtr( pCmdTree ) );
282 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
283 vlc_value_t oldVal, vlc_value_t newVal,
288 VlcProc *pThis = (VlcProc*)pParam;
290 // Create a raise all command
291 CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
292 pThis->getIntf()->p_sys->p_theme->getWindowManager() );
294 // Push the command in the asynchronous command queue
295 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
296 pQueue->push( CmdGenericPtr( pCmd ) );
302 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
303 vlc_value_t oldval, vlc_value_t newval, void *pParam )
305 VlcProc *pThis = (VlcProc*)pParam;
306 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
308 var_AddCallback( pInput, "intf-event", onGenericCallback, pThis );
309 var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
310 var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
311 var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
317 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
318 vlc_value_t oldval, vlc_value_t newval,
321 VlcProc *pThis = (VlcProc*)pParam;
322 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
324 // Update the stream variable
325 pThis->updateStreamName();
327 // Create a playtree notify command
328 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
331 // Push the command in the asynchronous command queue
332 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
333 pQueue->push( CmdGenericPtr( pCmdTree ), true );
338 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
339 vlc_value_t oldVal, vlc_value_t newVal,
342 VlcProc *pThis = (VlcProc*)pParam;
344 playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
347 memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
349 CmdGenericPtr ptrTree;
350 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
352 ptrTree = CmdGenericPtr( pCmdTree );
354 // Push the command in the asynchronous command queue
355 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
356 pQueue->push( ptrTree , false );
361 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
362 vlc_value_t oldVal, vlc_value_t newVal,
365 VlcProc *pThis = (VlcProc*)pParam;
367 int i_id = newVal.i_int;
369 CmdGenericPtr ptrTree;
370 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
372 ptrTree = CmdGenericPtr( pCmdTree );
374 // Push the command in the asynchronous command queue
375 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
376 pQueue->push( ptrTree , false );
382 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
383 vlc_value_t oldVal, vlc_value_t newVal,
386 VlcProc *pThis = (VlcProc*)pParam;
388 // Create a playlist notify command
389 CmdChangeSkin *pCmd =
390 new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
392 // Push the command in the asynchronous command queue
393 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
394 pQueue->push( CmdGenericPtr( pCmd ) );
399 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
400 vlc_value_t oldVal, vlc_value_t newVal,
403 VlcProc *pThis = (VlcProc*)pParam;
404 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
406 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
407 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
408 pQueue->push( CmdGenericPtr( pCmd ) );
413 void VlcProc::updateStreamName()
415 // Create a update item command
416 CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
418 // Push the command in the asynchronous command queue
419 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
420 pQueue->push( CmdGenericPtr( pCmdItem ) );
423 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
424 vlc_value_t oldVal, vlc_value_t newVal,
427 VlcProc *pThis = (VlcProc*)pParam;
429 // Post a set equalizer bands command
430 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
433 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
434 pQueue->push( CmdGenericPtr( pCmd ) );
440 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
441 vlc_value_t oldVal, vlc_value_t newVal,
444 VlcProc *pThis = (VlcProc*)pParam;
445 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
447 // Post a set preamp command
448 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
449 (newVal.f_float + 20.0) / 40.0 );
450 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
451 pQueue->push( CmdGenericPtr( pCmd ) );
457 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
458 vlc_value_t oldVal, vlc_value_t newVal,
461 VlcProc *pThis = (VlcProc*)pParam;
462 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
464 CmdGeneric *pCmd = NULL;
466 #define ADD_CALLBACK_ENTRY( var, label ) \
468 if( strcmp( pVariable, var ) == 0 ) \
469 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
472 ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
473 ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
475 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
476 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
477 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
478 ADD_CALLBACK_ENTRY( "can-record", can_record_changed )
480 ADD_CALLBACK_ENTRY( "random", random_changed )
481 ADD_CALLBACK_ENTRY( "loop", loop_changed )
482 ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
484 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
486 #undef ADD_CALLBACK_ENTRY
489 pQueue->push( CmdGenericPtr( pCmd ), false );
491 msg_Err( pObj, "no Callback entry provided for %s", pVariable );
496 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
498 playlist_t * pPlaylist = getIntf()->p_sys->p_playlist;
499 input_thread_t* pInput = getIntf()->p_sys->p_input;
500 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
505 pInput = playlist_CurrentInput( pPlaylist );
507 getIntf()->p_sys->p_input = pInput;
509 // Update the stream variable
512 // Create a playtree notify command
513 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
514 CmdPlaytreeUpdate *pCmdTree =
515 new CmdPlaytreeUpdate( getIntf(), p_item->i_id );
516 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
519 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
521 input_thread_t* pInput = (input_thread_t*) p_obj;
523 StreamTime *pTime = (StreamTime*)m_cVarTime.get();
524 VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
525 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
526 VarBoolImpl *pVarRecording = (VarBoolImpl*)m_cVarRecording.get();
527 VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
528 VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
529 VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
530 VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
531 VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
532 VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
533 VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
534 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
536 switch( newVal.i_int )
538 case INPUT_EVENT_STATE:
540 int state = var_GetInteger( pInput, "state" );
541 pVarStopped->set( false );
542 pVarPlaying->set( state != PAUSE_S );
543 pVarPaused->set( state == PAUSE_S );
547 case INPUT_EVENT_POSITION:
549 float pos = var_GetFloat( pInput, "position" );
550 pTime->set( pos, false );
551 pVarSeekable->set( pos != 0.0 );
558 vlc_value_t audio_es;
559 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
561 pVarHasAudio->set( audio_es.i_int > 0 );
565 case INPUT_EVENT_VOUT:
567 vout_thread_t* pVout = input_GetVout( pInput );
568 pVarHasVout->set( pVout != NULL );
571 pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
572 vlc_object_release( pVout );
577 case INPUT_EVENT_AOUT:
579 aout_instance_t* pAout = input_GetAout( pInput );
581 // end of input or aout reuse (nothing to do)
582 if( !pAout || pAout == m_pAout )
585 vlc_object_release( pAout );
589 // remove previous Aout if any
592 var_DelCallback( m_pAout, "audio-filter",
593 onGenericCallback, this );
594 if( m_bEqualizer_started )
596 var_DelCallback( m_pAout, "equalizer-bands",
597 onEqBandsChange, this );
598 var_DelCallback( m_pAout, "equalizer-preamp",
599 onEqPreampChange, this );
601 vlc_object_release( m_pAout );
603 m_bEqualizer_started = false;
606 // New Aout (addCallbacks)
607 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
609 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
610 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
612 pVarEqualizer->set( b_equalizer );
615 var_AddCallback( pAout, "equalizer-bands",
616 onEqBandsChange, this );
617 var_AddCallback( pAout, "equalizer-preamp",
618 onEqPreampChange, this );
619 m_bEqualizer_started = true;
625 case INPUT_EVENT_CHAPTER:
627 vlc_value_t chapters_count;
628 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
629 &chapters_count, NULL );
630 pVarDvdActive->set( chapters_count.i_int > 0 );
634 case INPUT_EVENT_RECORD:
635 pVarRecording->set( var_GetBool( pInput, "record" ) );
638 case INPUT_EVENT_DEAD:
647 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
649 input_thread_t* pInput = (input_thread_t*) p_obj;
651 VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
653 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
654 pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
657 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
659 input_thread_t* pInput = (input_thread_t*) p_obj;
661 VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
663 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
664 pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
667 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
669 input_thread_t* pInput = (input_thread_t*) p_obj;
671 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
672 pVarRecordable->set( var_GetBool( pInput, "can-record" ) );
675 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
677 playlist_t* pPlaylist = (playlist_t*) p_obj;
679 // Refresh the random variable
680 VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
681 pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
684 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
686 playlist_t* pPlaylist = (playlist_t*) p_obj;
688 // Refresh the loop variable
689 VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
690 pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
693 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
695 playlist_t* pPlaylist = (playlist_t*) p_obj;
697 // Refresh the repeat variable
698 VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
699 pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
702 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
704 (void)p_obj; (void)newVal;
705 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
707 // Refresh sound volume
708 audio_volume_t volume;
709 aout_VolumeGet( pPlaylist, &volume );
710 Volume *pVolume = (Volume*)m_cVarVolume.get();
711 pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
713 // Set the mute variable
714 VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
715 pVarMute->set( volume == 0 );
718 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
720 aout_instance_t* pAout = (aout_instance_t*) p_obj;
721 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
723 char *pFilters = newVal.psz_string;
725 // Refresh the equalizer variable
726 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
727 pVarEqualizer->set( b_equalizer );
728 if( b_equalizer && !m_bEqualizer_started )
730 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
731 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
732 m_bEqualizer_started = true;
736 void VlcProc::reset_input()
738 input_thread_t* pInput = getIntf()->p_sys->p_input;
742 StreamTime *pTime = (StreamTime*)m_cVarTime.get();
743 VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
744 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
745 VarBoolImpl *pVarRecording = (VarBoolImpl*)m_cVarRecording.get();
746 VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
747 VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
748 VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
749 VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
750 VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
751 VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
752 VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
753 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
755 VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
756 VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
758 pVarSeekable->set( false );
759 pVarRecordable->set( false );
760 pVarRecording->set( false );
761 pVarDvdActive->set( false );
762 pTime->set( 0, false );
763 pVarFullscreen->set( false );
764 pVarHasAudio->set( false );
765 pVarHasVout->set( false );
766 pVarStopped->set( true );
767 pVarPlaying->set( false );
768 pVarPaused->set( false );
769 pBitrate->set( UString( getIntf(), "") );
770 pSampleRate->set( UString( getIntf(), "") );
772 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
773 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
774 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
775 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
776 vlc_object_release( pInput );
777 getIntf()->p_sys->p_input = NULL;
781 void VlcProc::init_variables()
783 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
785 // Refresh the random variable
786 VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
787 pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
789 // Refresh the loop variable
790 VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
791 pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
793 // Refresh the repeat variable
794 VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
795 pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
797 // Refresh sound volume
798 audio_volume_t volume;
799 aout_VolumeGet( pPlaylist, &volume );
800 Volume *pVolume = (Volume*)m_cVarVolume.get();
801 pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
803 // Set the mute variable
804 VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
805 pVarMute->set( volume == 0 );
807 // Set the equalizer variable
811 void VlcProc::update_equalizer()
813 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
817 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
819 pFilters = config_GetPsz( getIntf(), "audio-filter" );
821 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
823 pVarEqualizer->set( b_equalizer );