1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003-2009 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
9 * Erwan Tulou <erwan10@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include <vlc_common.h>
33 #include <vlc_playlist.h>
35 #include "vlcproc.hpp"
36 #include "os_factory.hpp"
37 #include "os_loop.hpp"
38 #include "os_timer.hpp"
39 #include "var_manager.hpp"
40 #include "vout_manager.hpp"
42 #include "window_manager.hpp"
43 #include "../commands/async_queue.hpp"
44 #include "../commands/cmd_change_skin.hpp"
45 #include "../commands/cmd_show_window.hpp"
46 #include "../commands/cmd_quit.hpp"
47 #include "../commands/cmd_resize.hpp"
48 #include "../commands/cmd_vars.hpp"
49 #include "../commands/cmd_dialogs.hpp"
50 #include "../commands/cmd_update_item.hpp"
51 #include "../commands/cmd_audio.hpp"
52 #include "../commands/cmd_callbacks.hpp"
53 #include "../utils/var_bool.hpp"
58 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
60 if( pIntf->p_sys->p_vlcProc == NULL )
62 pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
65 return pIntf->p_sys->p_vlcProc;
69 void VlcProc::destroy( intf_thread_t *pIntf )
71 delete pIntf->p_sys->p_vlcProc;
72 pIntf->p_sys->p_vlcProc = NULL;
76 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
77 m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
78 m_pVout( NULL ), m_pAout( NULL ), m_bEqualizer_started( false ),
81 // Create a timer to poll the status of the vlc
82 OSFactory *pOsFactory = OSFactory::instance( pIntf );
83 m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
84 m_pTimer->start( 100, false );
86 // Create and register VLC variables
87 VarManager *pVarManager = VarManager::instance( getIntf() );
89 #define REGISTER_VAR( var, type, name ) \
90 var = VariablePtr( new type( getIntf() ) ); \
91 pVarManager->registerVar( var, name );
92 REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
93 REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
94 REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
95 REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
96 pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
98 pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
99 pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
101 REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
102 REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
103 REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
105 /* Input variables */
106 pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
107 REGISTER_VAR( m_cVarTime, StreamTime, "time" )
108 REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
109 REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
111 REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" )
112 REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" )
115 REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
116 REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
119 REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
120 REGISTER_VAR( m_cVarVolume, Volume, "volume" )
121 REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
122 REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
123 REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
126 m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
127 pVarManager->registerVar( m_cVarStreamName, "streamName" );
128 m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
129 pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
130 m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
131 pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
132 m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
133 pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
135 // Register the equalizer bands
136 for( int i = 0; i < EqualizerBands::kNbBands; i++)
139 ss << "equalizer.band(" << i << ")";
140 pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
144 // The object variable callbacks are called from other VLC threads,
145 // so they must put commands in the queue and NOT do anything else
146 // (X11 calls are not reentrant)
148 // Called when volume sound changes
149 #define ADD_CALLBACK( p_object, var ) \
150 var_AddCallback( p_object, var, onGenericCallback, this );
152 ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
154 ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
155 ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
156 ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
157 ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
161 // Called when the playlist changes
162 var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
163 onIntfChange, this );
164 // Called when a playlist item is added
165 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
166 onItemAppend, this );
167 // Called when a playlist item is deleted
168 // TODO: properly handle item-deleted
169 var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
170 onItemDelete, this );
171 // Called when the "interface shower" wants us to show the skin
172 var_AddCallback( pIntf->p_libvlc, "intf-show",
174 // Called when the current input changes
175 var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
177 // Called when a playlist item changed
178 var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
179 onItemChange, this );
180 // Called when our skins2 demux wants us to load a new skin
181 var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
183 // Called when we have an interaction dialog to display
184 var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
185 var_AddCallback( pIntf, "interaction", onInteraction, this );
186 interaction_Register( pIntf );
188 // initialize variables refering to liblvc and playlist objects
200 vlc_object_release( m_pAout );
205 vlc_object_release( m_pVout );
209 interaction_Unregister( getIntf() );
211 var_DelCallback( getIntf()->p_libvlc, "volume-change",
212 onGenericCallback, this );
214 var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
215 onGenericCallback, this );
216 var_DelCallback( getIntf()->p_sys->p_playlist, "random",
217 onGenericCallback, this );
218 var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
219 onGenericCallback, this );
220 var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
221 onGenericCallback, this );
222 var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
223 onIntfChange, this );
224 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
225 onItemAppend, this );
226 var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
227 onItemDelete, this );
228 var_DelCallback( getIntf()->p_libvlc, "intf-show",
230 var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
232 var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
233 onItemChange, this );
234 var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
235 var_DelCallback( getIntf(), "interaction", onInteraction, this );
238 void VlcProc::manage()
240 // Did the user request to quit vlc ?
241 if( !vlc_object_alive( getIntf() ) )
243 // Get the instance of OSFactory
244 OSFactory *pOsFactory = OSFactory::instance( getIntf() );
246 // Exit the main OS loop
247 pOsFactory->getOSLoop()->exit();
253 void VlcProc::CmdManage::execute()
255 // Just forward to VlcProc
260 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
261 vlc_value_t oldVal, vlc_value_t newVal,
264 VlcProc *pThis = (VlcProc*)pParam;
266 // Update the stream variable
267 pThis->updateStreamName();
269 // Create a playtree notify command (for new style playtree)
270 CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
272 // Push the command in the asynchronous command queue
273 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
274 pQueue->push( CmdGenericPtr( pCmdTree ) );
280 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
281 vlc_value_t oldVal, vlc_value_t newVal,
286 VlcProc *pThis = (VlcProc*)pParam;
288 // Create a raise all command
289 CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
290 pThis->getIntf()->p_sys->p_theme->getWindowManager() );
292 // Push the command in the asynchronous command queue
293 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
294 pQueue->push( CmdGenericPtr( pCmd ) );
300 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
301 vlc_value_t oldval, vlc_value_t newval, void *pParam )
303 VlcProc *pThis = (VlcProc*)pParam;
304 input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
306 var_AddCallback( pInput, "intf-event", onGenericCallback, pThis );
307 var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
308 var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
309 var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
315 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
316 vlc_value_t oldval, vlc_value_t newval,
319 VlcProc *pThis = (VlcProc*)pParam;
320 input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
322 // Update the stream variable
323 pThis->updateStreamName();
325 // Create a playtree notify command
326 CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
329 // Push the command in the asynchronous command queue
330 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
331 pQueue->push( CmdGenericPtr( pCmdTree ), true );
336 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
337 vlc_value_t oldVal, vlc_value_t newVal,
340 VlcProc *pThis = (VlcProc*)pParam;
342 playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
345 memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
347 CmdGenericPtr ptrTree;
348 CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
350 ptrTree = CmdGenericPtr( pCmdTree );
352 // Push the command in the asynchronous command queue
353 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
354 pQueue->push( ptrTree , false );
359 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
360 vlc_value_t oldVal, vlc_value_t newVal,
363 VlcProc *pThis = (VlcProc*)pParam;
365 int i_id = newVal.i_int;
367 CmdGenericPtr ptrTree;
368 CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
370 ptrTree = CmdGenericPtr( pCmdTree );
372 // Push the command in the asynchronous command queue
373 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
374 pQueue->push( ptrTree , false );
380 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
381 vlc_value_t oldVal, vlc_value_t newVal,
384 VlcProc *pThis = (VlcProc*)pParam;
386 // Create a playlist notify command
387 CmdChangeSkin *pCmd =
388 new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
390 // Push the command in the asynchronous command queue
391 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
392 pQueue->push( CmdGenericPtr( pCmd ) );
397 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
398 vlc_value_t oldVal, vlc_value_t newVal,
401 VlcProc *pThis = (VlcProc*)pParam;
402 interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
404 CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
405 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
406 pQueue->push( CmdGenericPtr( pCmd ) );
411 void VlcProc::updateStreamName()
413 // Create a update item command
414 CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
416 // Push the command in the asynchronous command queue
417 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
418 pQueue->push( CmdGenericPtr( pCmdItem ) );
421 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
422 vlc_value_t oldVal, vlc_value_t newVal,
425 VlcProc *pThis = (VlcProc*)pParam;
427 // Post a set equalizer bands command
428 CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
431 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
432 pQueue->push( CmdGenericPtr( pCmd ) );
438 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
439 vlc_value_t oldVal, vlc_value_t newVal,
442 VlcProc *pThis = (VlcProc*)pParam;
443 EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
445 // Post a set preamp command
446 CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
447 (newVal.f_float + 20.0) / 40.0 );
448 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
449 pQueue->push( CmdGenericPtr( pCmd ) );
455 int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
456 vlc_value_t oldVal, vlc_value_t newVal,
459 VlcProc *pThis = (VlcProc*)pParam;
460 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
462 CmdGeneric *pCmd = NULL;
464 #define ADD_CALLBACK_ENTRY( var, label ) \
466 if( strcmp( pVariable, var ) == 0 ) \
467 pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
470 ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
471 ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
473 ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
474 ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
475 ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
476 ADD_CALLBACK_ENTRY( "can-record", can_record_changed )
478 ADD_CALLBACK_ENTRY( "random", random_changed )
479 ADD_CALLBACK_ENTRY( "loop", loop_changed )
480 ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
482 ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
484 #undef ADD_CALLBACK_ENTRY
487 pQueue->push( CmdGenericPtr( pCmd ), false );
489 msg_Err( pObj, "no Callback entry provided for %s", pVariable );
494 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
496 input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
498 // Update the stream variable
501 // Create a playtree notify command
502 AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
503 CmdPlaytreeUpdate *pCmdTree =
504 new CmdPlaytreeUpdate( getIntf(), p_item->i_id );
505 pQueue->push( CmdGenericPtr( pCmdTree ) , true );
508 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
509 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
510 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
511 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->set(v,b)
513 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
515 input_thread_t* pInput = (input_thread_t*) p_obj;
517 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
519 if( !getIntf()->p_sys->p_input )
521 msg_Dbg( getIntf(), "new input %p detected", pInput );
523 getIntf()->p_sys->p_input = pInput;
524 vlc_object_hold( pInput );
527 switch( newVal.i_int )
529 case INPUT_EVENT_STATE:
531 int state = var_GetInteger( pInput, "state" );
532 SET_BOOL( m_cVarStopped, false );
533 SET_BOOL( m_cVarPlaying, state != PAUSE_S );
534 SET_BOOL( m_cVarPaused, state == PAUSE_S );
538 case INPUT_EVENT_POSITION:
540 float pos = var_GetFloat( pInput, "position" );
541 SET_STREAMTIME( m_cVarTime, pos, false );
542 SET_BOOL( m_cVarSeekable, pos != 0.0 );
549 vlc_value_t audio_es;
550 var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
552 SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
556 case INPUT_EVENT_VOUT:
558 vout_thread_t* pVout = input_GetVout( pInput );
559 SET_BOOL( m_cVarHasVout, pVout != NULL );
562 SET_BOOL( m_cVarFullscreen,
563 var_GetBool( pVout, "fullscreen" ) );
564 vlc_object_release( pVout );
569 case INPUT_EVENT_AOUT:
571 aout_instance_t* pAout = input_GetAout( pInput );
573 // end of input or aout reuse (nothing to do)
574 if( !pAout || pAout == m_pAout )
577 vlc_object_release( pAout );
581 // remove previous Aout if any
584 var_DelCallback( m_pAout, "audio-filter",
585 onGenericCallback, this );
586 if( m_bEqualizer_started )
588 var_DelCallback( m_pAout, "equalizer-bands",
589 onEqBandsChange, this );
590 var_DelCallback( m_pAout, "equalizer-preamp",
591 onEqPreampChange, this );
593 vlc_object_release( m_pAout );
595 m_bEqualizer_started = false;
598 // New Aout (addCallbacks)
599 var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
601 char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
602 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
604 SET_BOOL( m_cVarEqualizer, b_equalizer );
607 var_AddCallback( pAout, "equalizer-bands",
608 onEqBandsChange, this );
609 var_AddCallback( pAout, "equalizer-preamp",
610 onEqPreampChange, this );
611 m_bEqualizer_started = true;
617 case INPUT_EVENT_CHAPTER:
619 vlc_value_t chapters_count;
620 var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
621 &chapters_count, NULL );
622 SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
626 case INPUT_EVENT_RECORD:
627 SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
630 case INPUT_EVENT_DEAD:
631 msg_Dbg( getIntf(), "end of input detected for %p", pInput );
633 var_DelCallback( pInput, "intf-event", onGenericCallback, this );
634 var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
635 var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
636 var_DelCallback( pInput, "can-record" , onGenericCallback, this );
637 vlc_object_release( pInput );
638 getIntf()->p_sys->p_input = NULL;
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 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
653 int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
654 SET_TEXT( m_cVarStreamBitRate, 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 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
663 int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
664 SET_TEXT( m_cVarStreamSampleRate, 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 assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
673 SET_BOOL( m_cVarRecordable, var_GetBool( pInput, "can-record" ) );
676 void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
678 playlist_t* pPlaylist = (playlist_t*) p_obj;
680 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
683 void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
685 playlist_t* pPlaylist = (playlist_t*) p_obj;
687 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
690 void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
692 playlist_t* pPlaylist = (playlist_t*) p_obj;
694 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
697 void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
699 (void)p_obj; (void)newVal;
700 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
702 audio_volume_t volume;
703 aout_VolumeGet( pPlaylist, &volume );
704 SET_VOLUME( m_cVarVolume, (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
705 SET_BOOL( m_cVarMute, volume == 0 );
708 void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
710 aout_instance_t* pAout = (aout_instance_t*) p_obj;
712 char *pFilters = newVal.psz_string;
714 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
715 SET_BOOL( m_cVarEqualizer, b_equalizer );
716 if( b_equalizer && !m_bEqualizer_started )
718 var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
719 var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
720 m_bEqualizer_started = true;
724 void VlcProc::reset_input()
726 SET_BOOL( m_cVarSeekable, false );
727 SET_BOOL( m_cVarRecordable, false );
728 SET_BOOL( m_cVarRecording, false );
729 SET_BOOL( m_cVarDvdActive, false );
730 SET_BOOL( m_cVarFullscreen, false );
731 SET_BOOL( m_cVarHasAudio, false );
732 SET_BOOL( m_cVarHasVout, false );
733 SET_BOOL( m_cVarStopped, true );
734 SET_BOOL( m_cVarPlaying, false );
735 SET_BOOL( m_cVarPaused, false );
737 SET_STREAMTIME( m_cVarTime, 0, false );
738 SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
739 SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
742 void VlcProc::init_variables()
744 playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
746 SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
747 SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
748 SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
750 audio_volume_t volume;
751 aout_VolumeGet( pPlaylist, &volume );
752 SET_VOLUME( m_cVarVolume, (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
753 SET_BOOL( m_cVarMute, volume == 0 );
758 void VlcProc::update_equalizer()
763 pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
765 pFilters = config_GetPsz( getIntf(), "audio-filter" );
767 bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
770 SET_BOOL( m_cVarEqualizer, b_equalizer );
774 #undef SET_STREAMTIME