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>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
32 #include <vlc_playlist.h>
34 #include "vlcproc.hpp"
35 #include "os_factory.hpp"
36 #include "os_loop.hpp"
37 #include "os_timer.hpp"
38 #include "var_manager.hpp"
39 #include "vout_manager.hpp"
41 #include "window_manager.hpp"
42 #include "../commands/async_queue.hpp"
43 #include "../commands/cmd_change_skin.hpp"
44 #include "../commands/cmd_show_window.hpp"
45 #include "../commands/cmd_quit.hpp"
46 #include "../commands/cmd_resize.hpp"
47 #include "../commands/cmd_vars.hpp"
48 #include "../commands/cmd_dialogs.hpp"
49 #include "../commands/cmd_update_item.hpp"
50 #include "../commands/cmd_audio.hpp"
51 #include "../commands/cmd_callbacks.hpp"
52 #include "../utils/var_bool.hpp"
56 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
58 if( pIntf->p_sys->p_vlcProc == NULL )
60 pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
63 return pIntf->p_sys->p_vlcProc;
67 void VlcProc::destroy( intf_thread_t *pIntf )
69 delete pIntf->p_sys->p_vlcProc;
70 pIntf->p_sys->p_vlcProc = NULL;
74 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
75 m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
76 m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
78 // Create a timer to poll the status of the vlc
79 OSFactory *pOsFactory = OSFactory::instance( pIntf );
80 m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
81 m_pTimer->start( 100, false );
83 // Create and register VLC variables
84 VarManager *pVarManager = VarManager::instance( getIntf() );
86 #define REGISTER_VAR( var, type, name ) \
87 var = VariablePtr( new type( getIntf() ) ); \
88 pVarManager->registerVar( var, name );
89 REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
90 REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
91 REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
92 REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
93 pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
95 pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
96 pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
98 REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
99 REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
100 REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
102 /* Input variables */
103 pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
104 REGISTER_VAR( m_cVarTime, StreamTime, "time" )
105 REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
106 REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
108 REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" )
109 REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" )
112 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
113 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
116 REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
117 REGISTER_VAR( m_cVarVolume, Volume, "volume" )
118 REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
119 REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
120 REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
123 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
124 pVarManager->registerVar( m_cVarStreamName, "streamName" );
125 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
126 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
127 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
128 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
129 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
130 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
132 // Register the equalizer bands
133 for( int i = 0; i < EqualizerBands::kNbBands; i++)
136 ss << "equalizer.band(" << i << ")";
137 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
141 // The object variable callbacks are called from other VLC threads,
142 // so they must put commands in the queue and NOT do anything else
143 // (X11 calls are not reentrant)
145 // Called when volume sound changes
146 #define ADD_CALLBACK( p_object, var ) \
147 var_AddCallback( p_object, var, onGenericCallback, this );
149 ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
151 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
152 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
153 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
154 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
158 // Called when the playlist changes
159 var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
160 onIntfChange, this );
161 // Called when a playlist item is added
162 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
163 onItemAppend, this );
164 // Called when a playlist item is deleted
165 // TODO: properly handle item-deleted
166 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
167 onItemDelete, this );
168 // Called when the "interface shower" wants us to show the skin
169 var_AddCallback( pIntf->p_libvlc, "intf-show",
171 // Called when the current played item changes
172 var_AddCallback( pIntf->p_sys->p_playlist, "item-current",
173 onPlaylistChange, this );
174 // Called when a playlist item changed
175 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
176 onItemChange, this );
177 // Called when our skins2 demux wants us to load a new skin
178 var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
180 // Called when we have an interaction dialog to display
181 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
182 var_AddCallback( pIntf, "interaction", onInteraction, this );
183 interaction_Register( pIntf );
185 getIntf()->p_sys->p_input = NULL;
196 vlc_object_release( m_pAout );
201 vlc_object_release( m_pVout );
205 input_thread_t* pInput = getIntf()->p_sys->p_input;
208 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
209 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
210 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
211 var_DelCallback( pInput, "can-Record", onGenericCallback, this );
213 vlc_object_release( pInput );
214 getIntf()->p_sys->p_input = NULL;
217 interaction_Unregister( getIntf() );
219 var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
220 onIntfChange, this );
221 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
222 onItemAppend, this );
223 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
224 onItemDelete, this );
225 var_DelCallback( getIntf()->p_libvlc, "intf-show",
227 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
228 onGenericCallback, this );
229 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
230 onPlaylistChange, this );
231 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
232 onItemChange, this );
233 var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
234 var_DelCallback( getIntf(), "interaction", onInteraction, this );
237 void VlcProc::manage()
239 // Did the user request to quit vlc ?
240 if( !vlc_object_alive( getIntf() ) )
242 // Get the instance of OSFactory
243 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
245 // Exit the main OS loop
246 pOsFactory->getOSLoop()->exit();
252 void VlcProc::CmdManage::execute()
254 // Just forward to VlcProc
259 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
260 vlc_value_t oldVal, vlc_value_t newVal,
263 VlcProc *pThis = (VlcProc*)pParam;
265 // Update the stream variable
266 pThis->updateStreamName();
268 // Create a playtree notify command (for new style playtree)
269 CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
271 // Push the command in the asynchronous command queue
272 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
273 pQueue->push( CmdGenericPtr( pCmdTree ) );
279 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
280 vlc_value_t oldVal, vlc_value_t newVal,
285 VlcProc *pThis = (VlcProc*)pParam;
287 // Create a raise all command
288 CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
289 pThis->getIntf()->p_sys->p_theme->getWindowManager() );
291 // Push the command in the asynchronous command queue
292 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
293 pQueue->push( CmdGenericPtr( pCmd ) );
300 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
301 vlc_value_t oldval, vlc_value_t newval,
304 VlcProc *pThis = (VlcProc*)pParam;
305 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
307 // Update the stream variable
308 pThis->updateStreamName();
310 // Create a playtree notify command
311 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
314 // Push the command in the asynchronous command queue
315 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
316 pQueue->push( CmdGenericPtr( pCmdTree ), true );
321 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
322 vlc_value_t oldVal, vlc_value_t newVal,
325 VlcProc *pThis = (VlcProc*)pParam;
327 playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
330 memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
332 CmdGenericPtr ptrTree;
333 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
335 ptrTree = CmdGenericPtr( pCmdTree );
337 // Push the command in the asynchronous command queue
338 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
339 pQueue->push( ptrTree , false );
344 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
345 vlc_value_t oldVal, vlc_value_t newVal,
348 VlcProc *pThis = (VlcProc*)pParam;
350 int i_id = newVal.i_int;
352 CmdGenericPtr ptrTree;
353 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
355 ptrTree = CmdGenericPtr( pCmdTree );
357 // Push the command in the asynchronous command queue
358 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
359 pQueue->push( ptrTree , false );
365 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
366 vlc_value_t oldval, vlc_value_t newval,
369 VlcProc *pThis = (VlcProc*)pParam;
370 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
372 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
374 // Update the stream variable
375 pThis->updateStreamName();
377 // Create two playtree notify commands: one for old item, one for new
378 #if 0 /* FIXME: Heck, no! You cannot do that.
379 There is no warranty that the old item is still valid. */
380 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
382 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
384 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), p_item->i_id );
385 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
391 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
392 vlc_value_t oldVal, vlc_value_t newVal,
395 VlcProc *pThis = (VlcProc*)pParam;
397 // Create a playlist notify command
398 CmdChangeSkin *pCmd =
399 new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
401 // Push the command in the asynchronous command queue
402 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
403 pQueue->push( CmdGenericPtr( pCmd ) );
408 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
409 vlc_value_t oldVal, vlc_value_t newVal,
412 VlcProc *pThis = (VlcProc*)pParam;
413 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
415 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
416 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
417 pQueue->push( CmdGenericPtr( pCmd ) );
422 void VlcProc::updateStreamName()
424 // Create a update item command
425 CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
427 // Push the command in the asynchronous command queue
428 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
429 pQueue->push( CmdGenericPtr( pCmdItem ) );
432 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
433 vlc_value_t oldVal, vlc_value_t newVal,
436 VlcProc *pThis = (VlcProc*)pParam;
438 // Post a set equalizer bands command
439 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
442 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
443 pQueue->push( CmdGenericPtr( pCmd ) );
449 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
450 vlc_value_t oldVal, vlc_value_t newVal,
453 VlcProc *pThis = (VlcProc*)pParam;
454 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
456 // Post a set preamp command
457 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
458 (newVal.f_float + 20.0) / 40.0 );
459 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
460 pQueue->push( CmdGenericPtr( pCmd ) );
466 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
467 vlc_value_t oldVal, vlc_value_t newVal,
470 VlcProc *pThis = (VlcProc*)pParam;
471 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
473 CmdGeneric *pCmd = NULL;
475 #define ADD_CALLBACK_ENTRY( var, label ) \
477 if( strcmp( pVariable, var ) == 0 ) \
478 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
481 ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
482 ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
484 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
485 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
486 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
487 ADD_CALLBACK_ENTRY( "can-record", can_record_changed )
489 ADD_CALLBACK_ENTRY( "random", random_changed )
490 ADD_CALLBACK_ENTRY( "loop", loop_changed )
491 ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
493 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
495 #undef ADD_CALLBACK_ENTRY
498 pQueue->push( CmdGenericPtr( pCmd ), false );
500 msg_Err( pObj, "no Callback entry provided for %s", pVariable );
505 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
507 input_thread_t* pInput = getIntf()->p_sys->p_input;
510 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
511 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
512 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
513 var_DelCallback( pInput, "can-record", onGenericCallback, this );
514 vlc_object_release( pInput );
515 pInput = getIntf()->p_sys->p_input = NULL;
518 playlist_t * pPlaylist = getIntf()->p_sys->p_playlist;
519 pInput = playlist_CurrentInput( pPlaylist );
523 var_AddCallback( pInput, "intf-event", onGenericCallback, this );
524 var_AddCallback( pInput, "bit-rate", onGenericCallback, this );
525 var_AddCallback( pInput, "sample-rate", onGenericCallback, this );
526 var_AddCallback( pInput, "can-record", onGenericCallback, this );
527 getIntf()->p_sys->p_input = pInput;
530 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
532 input_thread_t* pInput = (input_thread_t*) p_obj;
534 StreamTime *pTime = (StreamTime*)m_cVarTime.get();
535 VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
536 VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
537 VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
538 VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
539 VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
540 VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
541 VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
542 VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
543 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
545 if( vlc_object_alive( pInput ) )
547 switch( newVal.i_int )
549 case INPUT_EVENT_STATE:
551 int state = var_GetInteger( pInput, "state" );
552 pVarStopped->set( false );
553 pVarPlaying->set( state != PAUSE_S );
554 pVarPaused->set( state == PAUSE_S );
558 case INPUT_EVENT_POSITION:
560 float pos = var_GetFloat( pInput, "position" );
561 pTime->set( pos, false );
562 pVarSeekable->set( pos != 0.0 );
569 vlc_value_t audio_es;
570 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
572 pVarHasAudio->set( audio_es.i_int > 0 );
576 case INPUT_EVENT_VOUT:
578 vout_thread_t* pVout = input_GetVout( pInput );
579 pVarHasVout->set( pVout != NULL );
582 pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
583 vlc_object_release( pVout );
588 case INPUT_EVENT_AOUT:
591 aout_instance_t* pAout = input_GetAout( pInput );
596 var_DelCallback( m_pAout, "audio-filter",
597 onGenericCallback, this );
598 var_DelCallback( m_pAout, "equalizer-bands",
599 onEqBandsChange, this );
600 var_DelCallback( m_pAout, "equalizer-preamp",
601 onEqPreampChange, this );
602 vlc_object_release( m_pAout );
606 var_AddCallback( pAout, "audio-filter",
607 onGenericCallback, this );
608 var_AddCallback( pAout, "equalizer-bands",
609 onEqBandsChange, this );
610 var_AddCallback( pAout, "equalizer-preamp",
611 onEqPreampChange, this );
614 pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
620 var_DelCallback( m_pAout, "audio-filter",
621 onGenericCallback, this );
622 var_DelCallback( m_pAout, "equalizer-bands",
623 onEqBandsChange, this );
624 var_DelCallback( m_pAout, "equalizer-preamp",
625 onEqPreampChange, this );
626 vlc_object_release( m_pAout );
629 // Get the audio filters
630 pFilters = config_GetPsz( getIntf(), "audio-filter" );
632 // Refresh the equalizer variable
633 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
634 pVarEqualizer->set( b_equalizer );
639 case INPUT_EVENT_CHAPTER:
641 vlc_value_t chapters_count;
642 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
643 &chapters_count, NULL );
644 pVarDvdActive->set( chapters_count.i_int > 0 );
648 case INPUT_EVENT_RECORD:
650 VarBoolImpl *pVarRecording =
651 (VarBoolImpl*)m_cVarRecording.get();
652 pVarRecording->set( var_GetBool( pInput, "record" ) );
659 var_DelCallback( pInput, "intf-event",
660 onGenericCallback, this );
661 var_DelCallback( pInput, "bit-rate",
662 onGenericCallback, this );
663 var_DelCallback( pInput, "sample-rate",
664 onGenericCallback, this );
665 var_DelCallback( pInput, "can-record" ,
666 onGenericCallback, this );
667 vlc_object_release( pInput );
668 getIntf()->p_sys->p_input = NULL;
678 // pVarSeekable->set( false );
679 pVarDvdActive->set( false );
680 pTime->set( 0, false );
681 pVarFullscreen->set( false );
682 pVarHasAudio->set( false );
683 pVarHasVout->set( false );
684 pVarStopped->set( true );
685 pVarPlaying->set( false );
686 pVarPaused->set( false );
690 void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
692 input_thread_t* pInput = (input_thread_t*) p_obj;
694 VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
696 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
697 pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
700 void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
702 input_thread_t* pInput = (input_thread_t*) p_obj;
704 VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
706 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
707 pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
710 void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
712 input_thread_t* pInput = (input_thread_t*) p_obj;
714 VarBoolImpl *pVarRecordable = (VarBoolImpl*)m_cVarRecordable.get();
715 pVarRecordable->set( var_GetBool( pInput, "can-record" ) );
718 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
720 playlist_t* pPlaylist = (playlist_t*) p_obj;
722 // Refresh the random variable
723 VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
724 pVarRandom->set( var_GetBool( pPlaylist, "random" ) );
727 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
729 playlist_t* pPlaylist = (playlist_t*) p_obj;
731 // Refresh the loop variable
732 VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
733 pVarLoop->set( var_GetBool( pPlaylist, "loop" ) );
736 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
738 playlist_t* pPlaylist = (playlist_t*) p_obj;
740 // Refresh the repeat variable
741 VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
742 pVarRepeat->set( var_GetBool( pPlaylist, "repeat" ) );
746 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
748 (void)p_obj; (void)newVal;
749 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
751 // Refresh sound volume
752 audio_volume_t volume;
753 aout_VolumeGet( pPlaylist, &volume );
754 Volume *pVolume = (Volume*)m_cVarVolume.get();
755 pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
757 // Set the mute variable
758 VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
759 pVarMute->set( volume == 0 );
762 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
764 aout_instance_t* pAout = (aout_instance_t*) p_obj;
766 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
768 VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
770 // Refresh the equalizer variable
771 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
772 pVarEqualizer->set( b_equalizer );