6dc6eff2b49bf384bf959d7a58e89a3726f4336b
[vlc.git] / 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     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 the playlist changes
142     var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
143                      onIntfChange, this );
144     // Called when a playlist item is added
145     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
146                      onItemAppend, this );
147     // Called when a playlist item is deleted
148     // TODO: properly handle item-deleted
149     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
150                      onItemDelete, this );
151     // Called when the "interface shower" wants us to show the skin
152     var_AddCallback( pIntf->p_libvlc, "intf-show",
153                      onIntfShow, this );
154     // Called when the current played item changes
155     var_AddCallback( pIntf->p_sys->p_playlist, "item-current",
156                      onPlaylistChange, this );
157     // Called when a playlist item changed
158     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
159                      onItemChange, this );
160     // Called when our skins2 demux wants us to load a new skin
161     var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
162
163     // Called when we have an interaction dialog to display
164     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
165     var_AddCallback( pIntf, "interaction", onInteraction, this );
166     interaction_Register( pIntf );
167
168     getIntf()->p_sys->p_input = NULL;
169 }
170
171
172 VlcProc::~VlcProc()
173 {
174     m_pTimer->stop();
175     delete( m_pTimer );
176     if( getIntf()->p_sys->p_input )
177     {
178         vlc_object_release( getIntf()->p_sys->p_input );
179         getIntf()->p_sys->p_input = NULL;
180     }
181
182     interaction_Unregister( getIntf() );
183
184     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
185                      onIntfChange, this );
186     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
187                      onItemAppend, this );
188     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
189                      onItemDelete, this );
190     var_DelCallback( getIntf()->p_libvlc, "intf-show",
191                      onIntfShow, this );
192     var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
193                      onPlaylistChange, this );
194     var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
195                      onItemChange, this );
196     var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
197     var_DelCallback( getIntf(), "interaction", onInteraction, this );
198 }
199
200 void VlcProc::manage()
201 {
202     // Did the user request to quit vlc ?
203     if( !vlc_object_alive( getIntf() ) )
204     {
205         // Get the instance of OSFactory
206         OSFactory *pOsFactory = OSFactory::instance( getIntf() );
207
208         // Exit the main OS loop
209         pOsFactory->getOSLoop()->exit();
210
211         return;
212     }
213
214     refreshPlaylist();
215     refreshAudio();
216     refreshInput();
217 }
218
219 void VlcProc::CmdManage::execute()
220 {
221     // Just forward to VlcProc
222     m_pParent->manage();
223 }
224
225 void VlcProc::refreshAudio()
226 {
227     char *pFilters;
228
229     // Check if the audio output has changed
230     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
231             VLC_OBJECT_AOUT, FIND_ANYWHERE );
232     if( pAout )
233     {
234         if( pAout != m_pAout )
235         {
236             // Register the equalizer callbacks
237             if( !var_AddCallback( pAout, "equalizer-bands",
238                                   onEqBandsChange, this ) &&
239                 !var_AddCallback( pAout, "equalizer-preamp",
240                                   onEqPreampChange, this ) )
241             {
242                 m_pAout = pAout;
243                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
244             }
245         }
246         // Get the audio filters
247         pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
248         vlc_object_release( pAout );
249     }
250     else
251     {
252         // Get the audio filters
253         pFilters = config_GetPsz( getIntf(), "audio-filter" );
254     }
255
256     // Refresh sound volume
257     audio_volume_t volume;
258     aout_VolumeGet( getIntf()->p_sys->p_playlist, &volume );
259     Volume *pVolume = (Volume*)m_cVarVolume.get();
260     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
261
262     // Set the mute variable
263     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
264     pVarMute->set( volume == 0 );
265
266     // Refresh the equalizer variable
267     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
268     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
269     free( pFilters );
270 }
271
272 void VlcProc::refreshPlaylist()
273 {
274     // Refresh the random variable
275     VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
276     vlc_value_t val;
277     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
278     pVarRandom->set( val.b_bool != 0 );
279
280     // Refresh the loop variable
281     VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
282     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
283     pVarLoop->set( val.b_bool != 0 );
284
285     // Refresh the repeat variable
286     VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
287     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
288     pVarRepeat->set( val.b_bool != 0 );
289 }
290
291 void VlcProc::refreshInput()
292 {
293     StreamTime *pTime = (StreamTime*)m_cVarTime.get();
294     VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
295     VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
296     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
297     VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
298     VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
299     VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
300     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
301     VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
302     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
303     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
304
305     // Update the input
306     if( getIntf()->p_sys->p_input == NULL )
307     {
308         getIntf()->p_sys->p_input =
309             playlist_CurrentInput( getIntf()->p_sys->p_playlist );
310     }
311     else if( getIntf()->p_sys->p_input->b_dead )
312     {
313         vlc_object_release( getIntf()->p_sys->p_input );
314         getIntf()->p_sys->p_input = NULL;
315     }
316
317     input_thread_t *pInput = getIntf()->p_sys->p_input;
318
319     if( pInput && vlc_object_alive (pInput) )
320     {
321         // Refresh time variables
322         vlc_value_t pos;
323         var_Get( pInput, "position", &pos );
324         pTime->set( pos.f_float, false );
325         pVarSeekable->set( pos.f_float != 0.0 );
326
327         // Refresh DVD detection
328         vlc_value_t chapters_count;
329         var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
330                         &chapters_count, NULL );
331         pVarDvdActive->set( chapters_count.i_int > 0 );
332
333         // Get the input bitrate
334         int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
335         pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
336
337         // Get the audio sample rate
338         int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
339         pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
340
341         // Do we have audio
342         vlc_value_t audio_es;
343         var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
344                         &audio_es, NULL );
345         pVarHasAudio->set( audio_es.i_int > 0 );
346
347         // Refresh fullscreen status
348         vout_thread_t *pVout = input_GetVout( pInput );
349         pVarHasVout->set( pVout != NULL );
350         if( pVout )
351         {
352             pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
353             vlc_object_release( pVout );
354         }
355
356         // Refresh play/pause status
357         int state = var_GetInteger( pInput, "state" );
358         pVarStopped->set( false );
359         pVarPlaying->set( state != PAUSE_S );
360         pVarPaused->set( state == PAUSE_S );
361     }
362     else
363     {
364         pVarSeekable->set( false );
365         pVarDvdActive->set( false );
366         pTime->set( 0, false );
367         pVarFullscreen->set( false );
368         pVarHasAudio->set( false );
369         pVarHasVout->set( false );
370         pVarStopped->set( true );
371         pVarPlaying->set( false );
372         pVarPaused->set( false );
373     }
374 }
375
376 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
377                            vlc_value_t oldVal, vlc_value_t newVal,
378                            void *pParam )
379 {
380     VlcProc *pThis = (VlcProc*)pParam;
381
382     // Update the stream variable
383     pThis->updateStreamName();
384
385     // Create a playtree notify command (for new style playtree)
386     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
387
388     // Push the command in the asynchronous command queue
389     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
390     pQueue->push( CmdGenericPtr( pCmdTree ) );
391
392     return VLC_SUCCESS;
393 }
394
395
396 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
397                          vlc_value_t oldVal, vlc_value_t newVal,
398                          void *pParam )
399 {
400     if (newVal.b_bool)
401     {
402         VlcProc *pThis = (VlcProc*)pParam;
403
404         // Create a raise all command
405         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
406             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
407
408         // Push the command in the asynchronous command queue
409         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
410         pQueue->push( CmdGenericPtr( pCmd ) );
411     }
412
413     return VLC_SUCCESS;
414 }
415
416
417 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
418                            vlc_value_t oldval, vlc_value_t newval,
419                            void *pParam )
420 {
421     VlcProc *pThis = (VlcProc*)pParam;
422     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
423
424     // Update the stream variable
425     pThis->updateStreamName();
426
427     // Create a playtree notify command
428     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
429                                                          p_item->i_id );
430
431     // Push the command in the asynchronous command queue
432     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
433     pQueue->push( CmdGenericPtr( pCmdTree ), true );
434
435     return VLC_SUCCESS;
436 }
437
438 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
439                            vlc_value_t oldVal, vlc_value_t newVal,
440                            void *pParam )
441 {
442     VlcProc *pThis = (VlcProc*)pParam;
443
444     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
445                                                 playlist_add_t ) ) ;
446
447     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
448
449     CmdGenericPtr ptrTree;
450     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
451                                                              p_add );
452     ptrTree = CmdGenericPtr( pCmdTree );
453
454     // Push the command in the asynchronous command queue
455     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
456     pQueue->push( ptrTree , false );
457
458     return VLC_SUCCESS;
459 }
460
461 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
462                            vlc_value_t oldVal, vlc_value_t newVal,
463                            void *pParam )
464 {
465     VlcProc *pThis = (VlcProc*)pParam;
466
467     int i_id = newVal.i_int;
468
469     CmdGenericPtr ptrTree;
470     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
471                                                          i_id);
472     ptrTree = CmdGenericPtr( pCmdTree );
473
474     // Push the command in the asynchronous command queue
475     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
476     pQueue->push( ptrTree , false );
477
478     return VLC_SUCCESS;
479 }
480
481
482 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
483                                vlc_value_t oldval, vlc_value_t newval,
484                                void *pParam )
485 {
486     VlcProc *pThis = (VlcProc*)pParam;
487     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
488
489     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
490
491     // Update the stream variable
492     pThis->updateStreamName();
493
494     // Create two playtree notify commands: one for old item, one for new
495 #if 0 /* FIXME: Heck, no! You cannot do that.
496          There is no warranty that the old item is still valid. */
497     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
498                                                          oldVal.i_int );
499     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
500 #endif
501     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), p_item->i_id );
502     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
503
504     return VLC_SUCCESS;
505 }
506
507
508 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
509                            vlc_value_t oldVal, vlc_value_t newVal,
510                            void *pParam )
511 {
512     VlcProc *pThis = (VlcProc*)pParam;
513
514     // Create a playlist notify command
515     CmdChangeSkin *pCmd =
516         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
517
518     // Push the command in the asynchronous command queue
519     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
520     pQueue->push( CmdGenericPtr( pCmd ) );
521
522     return VLC_SUCCESS;
523 }
524
525 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
526                             vlc_value_t oldVal, vlc_value_t newVal,
527                             void *pParam )
528 {
529     VlcProc *pThis = (VlcProc*)pParam;
530     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
531
532     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
533     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
534     pQueue->push( CmdGenericPtr( pCmd ) );
535     return VLC_SUCCESS;
536 }
537
538
539 void VlcProc::updateStreamName()
540 {
541     // Create a update item command
542     CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
543
544     // Push the command in the asynchronous command queue
545     AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
546     pQueue->push( CmdGenericPtr( pCmdItem ) );
547 }
548
549 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
550                               vlc_value_t oldVal, vlc_value_t newVal,
551                               void *pParam )
552 {
553     VlcProc *pThis = (VlcProc*)pParam;
554
555     // Post a set equalizer bands command
556     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
557                                              pThis->m_varEqBands,
558                                              newVal.psz_string );
559     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
560     pQueue->push( CmdGenericPtr( pCmd ) );
561
562     return VLC_SUCCESS;
563 }
564
565
566 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
567                                vlc_value_t oldVal, vlc_value_t newVal,
568                                void *pParam )
569 {
570     VlcProc *pThis = (VlcProc*)pParam;
571     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
572
573     // Post a set preamp command
574     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
575                                               (newVal.f_float + 20.0) / 40.0 );
576     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
577     pQueue->push( CmdGenericPtr( pCmd ) );
578
579     return VLC_SUCCESS;
580 }
581