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_cmdManage( this )
79 // Create a timer to poll the status of the vlc
80 OSFactory *pOsFactory = OSFactory::instance( pIntf );
81 m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
82 m_pTimer->start( 100, false );
84 // Create and register VLC variables
85 VarManager *pVarManager = VarManager::instance( getIntf() );
87 #define REGISTER_VAR( var, type, name ) \
88 var = VariablePtr( new type( getIntf() ) ); \
89 pVarManager->registerVar( var, name );
90 REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
91 REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
92 REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
93 REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
94 pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
96 pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
97 pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
99 REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
100 REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
101 REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
103 /* Input variables */
104 pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
105 REGISTER_VAR( m_cVarTime, StreamTime, "time" )
106 REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
107 REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
109 REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" )
110 REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" )
113 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
114 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
117 REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
118 REGISTER_VAR( m_cVarVolume, Volume, "volume" )
119 REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
120 REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
121 REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
124 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
125 pVarManager->registerVar( m_cVarStreamName, "streamName" );
126 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
127 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
128 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
129 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
130 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
131 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
133 // Register the equalizer bands
134 for( int i = 0; i < EqualizerBands::kNbBands; i++)
137 ss << "equalizer.band(" << i << ")";
138 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
142 // The object variable callbacks are called from other VLC threads,
143 // so they must put commands in the queue and NOT do anything else
144 // (X11 calls are not reentrant)
146 // Called when volume sound changes
147 #define ADD_CALLBACK( p_object, var ) \
148 var_AddCallback( p_object, var, onGenericCallback, this );
150 ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
152 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
153 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
154 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
155 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
159 // Called when the playlist changes
160 var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
161 onIntfChange, this );
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 "interface shower" wants us to show the skin
170 var_AddCallback( pIntf->p_libvlc, "intf-show",
172 // Called when the current input changes
173 var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
175 // Called when a playlist item changed
176 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
177 onItemChange, this );
178 // Called when our skins2 demux wants us to load a new skin
179 var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
181 // Called when we have an interaction dialog to display
182 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
183 var_AddCallback( pIntf, "interaction", onInteraction, this );
184 interaction_Register( pIntf );
186 // initialize variables refering to liblvc and playlist objects
198 vlc_object_release( m_pAout );
203 vlc_object_release( m_pVout );
207 if( getIntf()->p_sys->p_input )
210 interaction_Unregister( getIntf() );
212 var_DelCallback( getIntf()->p_libvlc, "volume-change",
213 onGenericCallback, this );
215 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
216 onGenericCallback, this );
217 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
218 onGenericCallback, this );
219 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
220 onGenericCallback, this );
221 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
222 onGenericCallback, this );
223 var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
224 onIntfChange, this );
225 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
226 onItemAppend, this );
227 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
228 onItemDelete, this );
229 var_DelCallback( getIntf()->p_libvlc, "intf-show",
231 var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
233 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
234 onItemChange, this );
235 var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
236 var_DelCallback( getIntf(), "interaction", onInteraction, this );
239 void VlcProc::manage()
241 // Did the user request to quit vlc ?
242 if( !vlc_object_alive( getIntf() ) )
244 // Get the instance of OSFactory
245 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
247 // Exit the main OS loop
248 pOsFactory->getOSLoop()->exit();
254 void VlcProc::CmdManage::execute()
256 // Just forward to VlcProc
261 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
262 vlc_value_t oldVal, vlc_value_t newVal,
265 VlcProc *pThis = (VlcProc*)pParam;
267 // Update the stream variable
268 pThis->updateStreamName();
270 // Create a playtree notify command (for new style playtree)
271 CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
273 // Push the command in the asynchronous command queue
274 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
275 pQueue->push( CmdGenericPtr( pCmdTree ) );
281 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
282 vlc_value_t oldVal, vlc_value_t newVal,
287 VlcProc *pThis = (VlcProc*)pParam;
289 // Create a raise all command
290 CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
291 pThis->getIntf()->p_sys->p_theme->getWindowManager() );
293 // Push the command in the asynchronous command queue
294 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
295 pQueue->push( CmdGenericPtr( pCmd ) );
301 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
302 vlc_value_t oldval, vlc_value_t newval, void *pParam )
304 VlcProc *pThis = (VlcProc*)pParam;
305 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
307 var_AddCallback( pInput, "intf-event", onGenericCallback, pThis );
308 var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
309 var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
310 var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
316 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
317 vlc_value_t oldval, vlc_value_t newval,
320 VlcProc *pThis = (VlcProc*)pParam;
321 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
323 // Update the stream variable
324 pThis->updateStreamName();
326 // Create a playtree notify command
327 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
330 // Push the command in the asynchronous command queue
331 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
332 pQueue->push( CmdGenericPtr( pCmdTree ), true );
337 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
338 vlc_value_t oldVal, vlc_value_t newVal,
341 VlcProc *pThis = (VlcProc*)pParam;
343 playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
346 memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
348 CmdGenericPtr ptrTree;
349 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
351 ptrTree = CmdGenericPtr( pCmdTree );
353 // Push the command in the asynchronous command queue
354 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
355 pQueue->push( ptrTree , false );
360 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
361 vlc_value_t oldVal, vlc_value_t newVal,
364 VlcProc *pThis = (VlcProc*)pParam;
366 int i_id = newVal.i_int;
368 CmdGenericPtr ptrTree;
369 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
371 ptrTree = CmdGenericPtr( pCmdTree );
373 // Push the command in the asynchronous command queue
374 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
375 pQueue->push( ptrTree , false );
381 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
382 vlc_value_t oldVal, vlc_value_t newVal,
385 VlcProc *pThis = (VlcProc*)pParam;
387 // Create a playlist notify command
388 CmdChangeSkin *pCmd =
389 new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
391 // Push the command in the asynchronous command queue
392 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
393 pQueue->push( CmdGenericPtr( pCmd ) );
398 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
399 vlc_value_t oldVal, vlc_value_t newVal,
402 VlcProc *pThis = (VlcProc*)pParam;
403 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
405 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
406 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
407 pQueue->push( CmdGenericPtr( pCmd ) );
412 void VlcProc::updateStreamName()
414 // Create a update item command
415 CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
417 // Push the command in the asynchronous command queue
418 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
419 pQueue->push( CmdGenericPtr( pCmdItem ) );
422 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
423 vlc_value_t oldVal, vlc_value_t newVal,
426 VlcProc *pThis = (VlcProc*)pParam;
428 // Post a set equalizer bands command
429 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
432 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
433 pQueue->push( CmdGenericPtr( pCmd ) );
439 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
440 vlc_value_t oldVal, vlc_value_t newVal,
443 VlcProc *pThis = (VlcProc*)pParam;
444 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
446 // Post a set preamp command
447 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
448 (newVal.f_float + 20.0) / 40.0 );
449 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
450 pQueue->push( CmdGenericPtr( pCmd ) );
456 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
457 vlc_value_t oldVal, vlc_value_t newVal,
460 VlcProc *pThis = (VlcProc*)pParam;
461 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
463 CmdGeneric *pCmd = NULL;
465 #define ADD_CALLBACK_ENTRY( var, label ) \
467 if( strcmp( pVariable, var ) == 0 ) \
468 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
471 ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
472 ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
474 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
475 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
476 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
477 ADD_CALLBACK_ENTRY( "can-record", can_record_changed )
479 ADD_CALLBACK_ENTRY( "random", random_changed )
480 ADD_CALLBACK_ENTRY( "loop", loop_changed )
481 ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
483 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
485 #undef ADD_CALLBACK_ENTRY
488 pQueue->push( CmdGenericPtr( pCmd ), false );
490 msg_Err( pObj, "no Callback entry provided for %s", pVariable );
495 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
497 playlist_t * pPlaylist = getIntf()->p_sys->p_playlist;
498 input_thread_t* pInput = getIntf()->p_sys->p_input;
499 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
504 pInput = playlist_CurrentInput( pPlaylist );
506 getIntf()->p_sys->p_input = pInput;
508 // Update the stream variable
511 // Create a playtree notify command
512 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
513 CmdPlaytreeUpdate *pCmdTree =
514 new CmdPlaytreeUpdate( getIntf(), p_item->i_id );
515 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
518 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
520 input_thread_t* pInput = (input_thread_t*) p_obj;
522 StreamTime *pTime = (StreamTime*)m_cVarTime.get();
523 VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
524 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
525 VarBoolImpl *pVarRecording = (VarBoolImpl*)m_cVarRecording.get();
526 VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
527 VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
528 VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
529 VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
530 VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
531 VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
532 VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
533 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
535 switch( newVal.i_int )
537 case INPUT_EVENT_STATE:
539 int state = var_GetInteger( pInput, "state" );
540 pVarStopped->set( false );
541 pVarPlaying->set( state != PAUSE_S );
542 pVarPaused->set( state == PAUSE_S );
546 case INPUT_EVENT_POSITION:
548 float pos = var_GetFloat( pInput, "position" );
549 pTime->set( pos, false );
550 pVarSeekable->set( pos != 0.0 );
557 vlc_value_t audio_es;
558 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
560 pVarHasAudio->set( audio_es.i_int > 0 );
564 case INPUT_EVENT_VOUT:
566 vout_thread_t* pVout = input_GetVout( pInput );
567 pVarHasVout->set( pVout != NULL );
570 pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
571 vlc_object_release( pVout );
576 case INPUT_EVENT_AOUT:
579 aout_instance_t* pAout = input_GetAout( pInput );
584 var_DelCallback( m_pAout, "audio-filter",
585 onGenericCallback, this );
586 var_DelCallback( m_pAout, "equalizer-bands",
587 onEqBandsChange, this );
588 var_DelCallback( m_pAout, "equalizer-preamp",
589 onEqPreampChange, this );
590 vlc_object_release( m_pAout );
594 var_AddCallback( pAout, "audio-filter",
595 onGenericCallback, this );
596 var_AddCallback( pAout, "equalizer-bands",
597 onEqBandsChange, this );
598 var_AddCallback( pAout, "equalizer-preamp",
599 onEqPreampChange, this );
602 pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
608 var_DelCallback( m_pAout, "audio-filter",
609 onGenericCallback, this );
610 var_DelCallback( m_pAout, "equalizer-bands",
611 onEqBandsChange, this );
612 var_DelCallback( m_pAout, "equalizer-preamp",
613 onEqPreampChange, this );
614 vlc_object_release( m_pAout );
617 // Get the audio filters
618 pFilters = config_GetPsz( getIntf(), "audio-filter" );
620 // Refresh the equalizer variable
621 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
622 pVarEqualizer->set( b_equalizer );
627 case INPUT_EVENT_CHAPTER:
629 vlc_value_t chapters_count;
630 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
631 &chapters_count, NULL );
632 pVarDvdActive->set( chapters_count.i_int > 0 );
636 case INPUT_EVENT_RECORD:
637 pVarRecording->set( var_GetBool( pInput, "record" ) );
640 case INPUT_EVENT_DEAD:
649 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
651 input_thread_t* pInput = (input_thread_t*) p_obj;
653 VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
655 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
656 pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
659 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
661 input_thread_t* pInput = (input_thread_t*) p_obj;
663 VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
665 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
666 pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
669 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
671 input_thread_t* pInput = (input_thread_t*) p_obj;
673 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
674 pVarRecordable->set( var_GetBool( pInput, "can-record" ) );
677 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
679 playlist_t* pPlaylist = (playlist_t*) p_obj;
681 // Refresh the random variable
682 VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
683 pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
686 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
688 playlist_t* pPlaylist = (playlist_t*) p_obj;
690 // Refresh the loop variable
691 VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
692 pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
695 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
697 playlist_t* pPlaylist = (playlist_t*) p_obj;
699 // Refresh the repeat variable
700 VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
701 pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
704 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
706 (void)p_obj; (void)newVal;
707 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
709 // Refresh sound volume
710 audio_volume_t volume;
711 aout_VolumeGet( pPlaylist, &volume );
712 Volume *pVolume = (Volume*)m_cVarVolume.get();
713 pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
715 // Set the mute variable
716 VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
717 pVarMute->set( volume == 0 );
720 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
722 aout_instance_t* pAout = (aout_instance_t*) p_obj;
724 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
726 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
728 // Refresh the equalizer variable
729 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
730 pVarEqualizer->set( b_equalizer );
734 void VlcProc::reset_input()
736 input_thread_t* pInput = getIntf()->p_sys->p_input;
740 StreamTime *pTime = (StreamTime*)m_cVarTime.get();
741 VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
742 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
743 VarBoolImpl *pVarRecording = (VarBoolImpl*)m_cVarRecording.get();
744 VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
745 VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
746 VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
747 VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
748 VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
749 VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
750 VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
751 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
753 VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
754 VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
756 pVarSeekable->set( false );
757 pVarRecordable->set( false );
758 pVarRecording->set( false );
759 pVarDvdActive->set( false );
760 pTime->set( 0, false );
761 pVarFullscreen->set( false );
762 pVarHasAudio->set( false );
763 pVarHasVout->set( false );
764 pVarStopped->set( true );
765 pVarPlaying->set( false );
766 pVarPaused->set( false );
767 pBitrate->set( UString( getIntf(), "") );
768 pSampleRate->set( UString( getIntf(), "") );
770 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
771 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
772 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
773 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
774 vlc_object_release( pInput );
775 getIntf()->p_sys->p_input = NULL;
779 void VlcProc::init_variables()
781 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
783 // Refresh the random variable
784 VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
785 pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
787 // Refresh the loop variable
788 VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
789 pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
791 // Refresh the repeat variable
792 VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
793 pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
795 // Refresh sound volume
796 audio_volume_t volume;
797 aout_VolumeGet( pPlaylist, &volume );
798 Volume *pVolume = (Volume*)m_cVarVolume.get();
799 pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
801 // Set the mute variable
802 VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
803 pVarMute->set( volume == 0 );