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