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