]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.cpp
skins2: replace all remaining FIND_ANYWHERE with more appropriate functions
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
1 /*****************************************************************************
2  * vlcproc.cpp
3  *****************************************************************************
4  * Copyright (C) 2003-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_common.h>
30 #include <vlc_aout.h>
31 #include <vlc_vout.h>
32 #include <vlc_playlist.h>
33
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"
40 #include "theme.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 "../utils/var_bool.hpp"
52 #include <sstream>
53
54
55 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
56 {
57     if( pIntf->p_sys->p_vlcProc == NULL )
58     {
59         pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
60     }
61
62     return pIntf->p_sys->p_vlcProc;
63 }
64
65
66 void VlcProc::destroy( intf_thread_t *pIntf )
67 {
68     delete pIntf->p_sys->p_vlcProc;
69     pIntf->p_sys->p_vlcProc = NULL;
70 }
71
72
73 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
74     m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
75     m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
76 {
77     // Create a timer to poll the status of the vlc
78     OSFactory *pOsFactory = OSFactory::instance( pIntf );
79     m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
80     m_pTimer->start( 100, false );
81
82     // Create and register VLC variables
83     VarManager *pVarManager = VarManager::instance( getIntf() );
84
85 #define REGISTER_VAR( var, type, name ) \
86     var = VariablePtr( new type( getIntf() ) ); \
87     pVarManager->registerVar( var, name );
88     REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
89     REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
90     REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
91     REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
92     pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
93                               "playtree.slider" );
94     pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
95     pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
96
97     REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
98     REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
99     REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
100
101     /* Input variables */
102     pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
103     REGISTER_VAR( m_cVarTime, StreamTime, "time" )
104     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
105     REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
106
107     /* Vout variables */
108     REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
109     REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
110
111     /* Aout variables */
112     REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
113     REGISTER_VAR( m_cVarVolume, Volume, "volume" )
114     REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
115     REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
116     REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
117
118 #undef REGISTER_VAR
119     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
120     pVarManager->registerVar( m_cVarStreamName, "streamName" );
121     m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
122     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
123     m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
124     pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
125     m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
126     pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
127
128     // Register the equalizer bands
129     for( int i = 0; i < EqualizerBands::kNbBands; i++)
130     {
131         stringstream ss;
132         ss << "equalizer.band(" << i << ")";
133         pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
134     }
135
136     // XXX WARNING XXX
137     // The object variable callbacks are called from other VLC threads,
138     // so they must put commands in the queue and NOT do anything else
139     // (X11 calls are not reentrant)
140
141     // Called when volume sound changes
142     var_AddCallback( pIntf->p_libvlc, "volume-change",
143                      onVolumeChanged, this );
144     // Called when the playlist changes
145     var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
146                      onIntfChange, this );
147     // Called when a playlist item is added
148     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
149                      onItemAppend, this );
150     // Called when a playlist item is deleted
151     // TODO: properly handle item-deleted
152     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
153                      onItemDelete, this );
154     // Called when the "interface shower" wants us to show the skin
155     var_AddCallback( pIntf->p_libvlc, "intf-show",
156                      onIntfShow, this );
157     // Called when the current played item changes
158     var_AddCallback( pIntf->p_sys->p_playlist, "item-current",
159                      onPlaylistChange, this );
160     // Called when a playlist item changed
161     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
162                      onItemChange, this );
163     // Called when our skins2 demux wants us to load a new skin
164     var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
165
166     // Called when we have an interaction dialog to display
167     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
168     var_AddCallback( pIntf, "interaction", onInteraction, this );
169     interaction_Register( pIntf );
170
171     getIntf()->p_sys->p_input = NULL;
172 }
173
174
175 VlcProc::~VlcProc()
176 {
177     m_pTimer->stop();
178     delete( m_pTimer );
179     if( getIntf()->p_sys->p_input )
180     {
181         vlc_object_release( getIntf()->p_sys->p_input );
182         getIntf()->p_sys->p_input = NULL;
183     }
184
185     interaction_Unregister( getIntf() );
186
187     var_DelCallback( getIntf()->p_libvlc, "volume-change",
188                      onVolumeChanged, this );
189     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
190                      onIntfChange, this );
191     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
192                      onItemAppend, this );
193     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
194                      onItemDelete, this );
195     var_DelCallback( getIntf()->p_libvlc, "intf-show",
196                      onIntfShow, this );
197     var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
198                      onPlaylistChange, this );
199     var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
200                      onItemChange, this );
201     var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
202     var_DelCallback( getIntf(), "interaction", onInteraction, this );
203 }
204
205 void VlcProc::manage()
206 {
207     // Did the user request to quit vlc ?
208     if( !vlc_object_alive( getIntf() ) )
209     {
210         // Get the instance of OSFactory
211         OSFactory *pOsFactory = OSFactory::instance( getIntf() );
212
213         // Exit the main OS loop
214         pOsFactory->getOSLoop()->exit();
215
216         return;
217     }
218
219     refreshPlaylist();
220     refreshAudio();
221     refreshInput();
222 }
223
224 void VlcProc::CmdManage::execute()
225 {
226     // Just forward to VlcProc
227     m_pParent->manage();
228 }
229
230 void VlcProc::refreshAudio()
231 {
232     char *pFilters;
233     aout_instance_t *pAout = NULL;
234
235     playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
236     input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
237     if( pInput )
238         pAout = input_GetAout( pInput );
239
240     if( pAout )
241     {
242         // Check if the audio output has changed
243         if( pAout != m_pAout )
244         {
245             // Register the equalizer callbacks
246             if( !var_AddCallback( pAout, "equalizer-bands",
247                                   onEqBandsChange, this ) &&
248                 !var_AddCallback( pAout, "equalizer-preamp",
249                                   onEqPreampChange, this ) )
250             {
251                 m_pAout = pAout;
252                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
253             }
254         }
255         // Get the audio filters
256         pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
257     }
258     else
259     {
260         // Get the audio filters
261         pFilters = config_GetPsz( getIntf(), "audio-filter" );
262     }
263
264     // Refresh the equalizer variable
265     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
266     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
267     free( pFilters );
268
269     if( pAout )
270         vlc_object_release( pAout );
271     if( pInput )
272         vlc_object_release( pInput );
273 }
274
275 void VlcProc::refreshVolume()
276 {
277     // Refresh sound volume
278     audio_volume_t volume;
279     aout_VolumeGet( getIntf()->p_sys->p_playlist, &volume );
280     Volume *pVolume = (Volume*)m_cVarVolume.get();
281     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX , false );
282
283     // Set the mute variable
284     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
285     pVarMute->set( volume == 0 );
286 }
287
288 void VlcProc::refreshPlaylist()
289 {
290     // Refresh the random variable
291     VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
292     vlc_value_t val;
293     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
294     pVarRandom->set( val.b_bool != 0 );
295
296     // Refresh the loop variable
297     VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
298     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
299     pVarLoop->set( val.b_bool != 0 );
300
301     // Refresh the repeat variable
302     VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
303     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
304     pVarRepeat->set( val.b_bool != 0 );
305 }
306
307 void VlcProc::refreshInput()
308 {
309     StreamTime *pTime = (StreamTime*)m_cVarTime.get();
310     VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
311     VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
312     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
313     VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
314     VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
315     VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
316     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
317     VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
318     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
319     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
320
321     // Update the input
322     if( getIntf()->p_sys->p_input == NULL )
323     {
324         getIntf()->p_sys->p_input =
325             playlist_CurrentInput( getIntf()->p_sys->p_playlist );
326     }
327     else if( getIntf()->p_sys->p_input->b_dead )
328     {
329         vlc_object_release( getIntf()->p_sys->p_input );
330         getIntf()->p_sys->p_input = NULL;
331     }
332
333     input_thread_t *pInput = getIntf()->p_sys->p_input;
334
335     if( pInput && vlc_object_alive (pInput) )
336     {
337         // Refresh time variables
338         vlc_value_t pos;
339         var_Get( pInput, "position", &pos );
340         pTime->set( pos.f_float, false );
341         pVarSeekable->set( pos.f_float != 0.0 );
342
343         // Refresh DVD detection
344         vlc_value_t chapters_count;
345         var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
346                         &chapters_count, NULL );
347         pVarDvdActive->set( chapters_count.i_int > 0 );
348
349         // Get the input bitrate
350         int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
351         pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
352
353         // Get the audio sample rate
354         int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
355         pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
356
357         // Do we have audio
358         vlc_value_t audio_es;
359         var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
360                         &audio_es, NULL );
361         pVarHasAudio->set( audio_es.i_int > 0 );
362
363         // Refresh fullscreen status
364         vout_thread_t *pVout = input_GetVout( pInput );
365         pVarHasVout->set( pVout != NULL );
366         if( pVout )
367         {
368             pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
369             vlc_object_release( pVout );
370         }
371
372         // Refresh play/pause status
373         int state = var_GetInteger( pInput, "state" );
374         pVarStopped->set( false );
375         pVarPlaying->set( state != PAUSE_S );
376         pVarPaused->set( state == PAUSE_S );
377     }
378     else
379     {
380         pVarSeekable->set( false );
381         pVarDvdActive->set( false );
382         pTime->set( 0, false );
383         pVarFullscreen->set( false );
384         pVarHasAudio->set( false );
385         pVarHasVout->set( false );
386         pVarStopped->set( true );
387         pVarPlaying->set( false );
388         pVarPaused->set( false );
389     }
390 }
391
392 int VlcProc::onVolumeChanged( vlc_object_t *pObj, const char *pVariable,
393                            vlc_value_t oldVal, vlc_value_t newVal,
394                            void *pParam )
395 {
396     VlcProc *pThis = (VlcProc*)pParam;
397
398     // Create a playtree notify command (for new style playtree)
399     CmdVolumeChanged *pCmd = new CmdVolumeChanged( pThis->getIntf() );
400
401     // Push the command in the asynchronous command queue
402     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
403     pQueue->push( CmdGenericPtr( pCmd ) );
404
405     return VLC_SUCCESS;
406 }
407
408
409 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
410                            vlc_value_t oldVal, vlc_value_t newVal,
411                            void *pParam )
412 {
413     VlcProc *pThis = (VlcProc*)pParam;
414
415     // Update the stream variable
416     pThis->updateStreamName();
417
418     // Create a playtree notify command (for new style playtree)
419     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
420
421     // Push the command in the asynchronous command queue
422     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
423     pQueue->push( CmdGenericPtr( pCmdTree ) );
424
425     return VLC_SUCCESS;
426 }
427
428
429 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
430                          vlc_value_t oldVal, vlc_value_t newVal,
431                          void *pParam )
432 {
433     if (newVal.b_bool)
434     {
435         VlcProc *pThis = (VlcProc*)pParam;
436
437         // Create a raise all command
438         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
439             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
440
441         // Push the command in the asynchronous command queue
442         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
443         pQueue->push( CmdGenericPtr( pCmd ) );
444     }
445
446     return VLC_SUCCESS;
447 }
448
449
450 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
451                            vlc_value_t oldval, vlc_value_t newval,
452                            void *pParam )
453 {
454     VlcProc *pThis = (VlcProc*)pParam;
455     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
456
457     // Update the stream variable
458     pThis->updateStreamName();
459
460     // Create a playtree notify command
461     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
462                                                          p_item->i_id );
463
464     // Push the command in the asynchronous command queue
465     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
466     pQueue->push( CmdGenericPtr( pCmdTree ), true );
467
468     return VLC_SUCCESS;
469 }
470
471 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
472                            vlc_value_t oldVal, vlc_value_t newVal,
473                            void *pParam )
474 {
475     VlcProc *pThis = (VlcProc*)pParam;
476
477     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
478                                                 playlist_add_t ) ) ;
479
480     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
481
482     CmdGenericPtr ptrTree;
483     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
484                                                              p_add );
485     ptrTree = CmdGenericPtr( pCmdTree );
486
487     // Push the command in the asynchronous command queue
488     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
489     pQueue->push( ptrTree , false );
490
491     return VLC_SUCCESS;
492 }
493
494 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
495                            vlc_value_t oldVal, vlc_value_t newVal,
496                            void *pParam )
497 {
498     VlcProc *pThis = (VlcProc*)pParam;
499
500     int i_id = newVal.i_int;
501
502     CmdGenericPtr ptrTree;
503     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
504                                                          i_id);
505     ptrTree = CmdGenericPtr( pCmdTree );
506
507     // Push the command in the asynchronous command queue
508     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
509     pQueue->push( ptrTree , false );
510
511     return VLC_SUCCESS;
512 }
513
514
515 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
516                                vlc_value_t oldval, vlc_value_t newval,
517                                void *pParam )
518 {
519     VlcProc *pThis = (VlcProc*)pParam;
520     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
521
522     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
523
524     // Update the stream variable
525     pThis->updateStreamName();
526
527     // Create two playtree notify commands: one for old item, one for new
528 #if 0 /* FIXME: Heck, no! You cannot do that.
529          There is no warranty that the old item is still valid. */
530     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
531                                                          oldVal.i_int );
532     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
533 #endif
534     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), p_item->i_id );
535     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
536
537     return VLC_SUCCESS;
538 }
539
540
541 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
542                            vlc_value_t oldVal, vlc_value_t newVal,
543                            void *pParam )
544 {
545     VlcProc *pThis = (VlcProc*)pParam;
546
547     // Create a playlist notify command
548     CmdChangeSkin *pCmd =
549         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
550
551     // Push the command in the asynchronous command queue
552     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
553     pQueue->push( CmdGenericPtr( pCmd ) );
554
555     return VLC_SUCCESS;
556 }
557
558 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
559                             vlc_value_t oldVal, vlc_value_t newVal,
560                             void *pParam )
561 {
562     VlcProc *pThis = (VlcProc*)pParam;
563     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
564
565     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
566     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
567     pQueue->push( CmdGenericPtr( pCmd ) );
568     return VLC_SUCCESS;
569 }
570
571
572 void VlcProc::updateStreamName()
573 {
574     // Create a update item command
575     CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
576
577     // Push the command in the asynchronous command queue
578     AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
579     pQueue->push( CmdGenericPtr( pCmdItem ) );
580 }
581
582 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
583                               vlc_value_t oldVal, vlc_value_t newVal,
584                               void *pParam )
585 {
586     VlcProc *pThis = (VlcProc*)pParam;
587
588     // Post a set equalizer bands command
589     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
590                                              pThis->m_varEqBands,
591                                              newVal.psz_string );
592     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
593     pQueue->push( CmdGenericPtr( pCmd ) );
594
595     return VLC_SUCCESS;
596 }
597
598
599 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
600                                vlc_value_t oldVal, vlc_value_t newVal,
601                                void *pParam )
602 {
603     VlcProc *pThis = (VlcProc*)pParam;
604     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
605
606     // Post a set preamp command
607     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
608                                               (newVal.f_float + 20.0) / 40.0 );
609     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
610     pQueue->push( CmdGenericPtr( pCmd ) );
611
612     return VLC_SUCCESS;
613 }
614