]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.cpp
8f2d815c9864fb7249d870f3341456c9864a7549
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
1 /*****************************************************************************
2  * vlcproc.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teuli�e <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 #include <vlc/aout.h>
26 #include <vlc/vout.h>
27 #include <aout_internal.h>
28
29 #include "vlcproc.hpp"
30 #include "os_factory.hpp"
31 #include "os_timer.hpp"
32 #include "var_manager.hpp"
33 #include "theme.hpp"
34 #include "window_manager.hpp"
35 #include "../commands/async_queue.hpp"
36 #include "../commands/cmd_change_skin.hpp"
37 #include "../commands/cmd_show_window.hpp"
38 #include "../commands/cmd_quit.hpp"
39 #include "../commands/cmd_resize.hpp"
40 #include "../commands/cmd_vars.hpp"
41 #include "../commands/cmd_dialogs.hpp"
42 #include "../utils/var_bool.hpp"
43 #include <sstream>
44
45
46 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
47 {
48     if( pIntf->p_sys->p_vlcProc == NULL )
49     {
50         pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
51     }
52
53     return pIntf->p_sys->p_vlcProc;
54 }
55
56
57 void VlcProc::destroy( intf_thread_t *pIntf )
58 {
59     if( pIntf->p_sys->p_vlcProc )
60     {
61         delete pIntf->p_sys->p_vlcProc;
62         pIntf->p_sys->p_vlcProc = NULL;
63     }
64 }
65
66
67 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
68     m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
69     m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
70 {
71     // Create a timer to poll the status of the vlc
72     OSFactory *pOsFactory = OSFactory::instance( pIntf );
73     m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
74     m_pTimer->start( 100, false );
75
76     // Create and register VLC variables
77     VarManager *pVarManager = VarManager::instance( getIntf() );
78
79 #define REGISTER_VAR( var, type, name ) \
80     var = VariablePtr( new type( getIntf() ) ); \
81     pVarManager->registerVar( var, name );
82     REGISTER_VAR( m_cPlaylist, Playlist, "playlist" )
83     pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(),
84                               "playlist.slider" );
85     REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
86     REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
87     REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
88     REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
89     pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
90                               "playtree.slider" );
91     pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
92     pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
93     pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
94     REGISTER_VAR( m_cVarTime, StreamTime, "time" )
95     REGISTER_VAR( m_cVarVolume, Volume, "volume" )
96     REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
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     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
101     REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
102     REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
103 #undef REGISTER_VAR
104     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
105     pVarManager->registerVar( m_cVarStreamName, "streamName" );
106     m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
107     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
108
109     // Register the equalizer bands
110     for( int i = 0; i < EqualizerBands::kNbBands; i++)
111     {
112         stringstream ss;
113         ss << "equalizer.band(" << i << ")";
114         pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
115     }
116
117     // XXX WARNING XXX
118     // The object variable callbacks are called from other VLC threads,
119     // so they must put commands in the queue and NOT do anything else
120     // (X11 calls are not reentrant)
121
122     // Called when the playlist changes
123     var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
124                      onIntfChange, this );
125     // Called when a playlist item is added
126     var_AddCallback( pIntf->p_sys->p_playlist, "item-append",
127                      onItemAppend, this );
128     // Called when a playlist item is deleted
129     // TODO: properly handle item-deleted
130     var_AddCallback( pIntf->p_sys->p_playlist, "item-deleted",
131                      onItemDelete, this );
132     // Called when the "interface shower" wants us to show the skin
133     var_AddCallback( pIntf->p_sys->p_playlist, "intf-show",
134                      onIntfShow, this );
135     // Called when the current played item changes
136     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
137                      onPlaylistChange, this );
138     // Called when a playlist item changed
139     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
140                      onItemChange, this );
141     // Called when our skins2 demux wants us to load a new skin
142     var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
143
144     // Called when we have an interaction dialog to display
145     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
146     var_AddCallback( pIntf, "interaction", onInteraction, this );
147     pIntf->b_interaction = VLC_TRUE;
148
149     // Callbacks for vout requests
150     getIntf()->pf_request_window = &getWindow;
151     getIntf()->pf_release_window = &releaseWindow;
152     getIntf()->pf_control_window = &controlWindow;
153
154     getIntf()->p_sys->p_input = NULL;
155 }
156
157
158 VlcProc::~VlcProc()
159 {
160     m_pTimer->stop();
161     delete( m_pTimer );
162     if( getIntf()->p_sys->p_input )
163     {
164         vlc_object_release( getIntf()->p_sys->p_input );
165     }
166
167     // Callbacks for vout requests
168     getIntf()->pf_request_window = NULL;
169     getIntf()->pf_release_window = NULL;
170     getIntf()->pf_control_window = NULL;
171
172     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
173                      onIntfChange, this );
174     var_DelCallback( getIntf()->p_sys->p_playlist, "item-append",
175                      onItemAppend, this );
176     var_DelCallback( getIntf()->p_sys->p_playlist, "item-deleted",
177                      onItemDelete, this );
178     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-show",
179                      onIntfShow, this );
180     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
181                      onPlaylistChange, this );
182     var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
183                      onItemChange, this );
184     var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
185 }
186
187
188 void VlcProc::registerVoutWindow( void *pVoutWindow )
189 {
190     m_handleSet.insert( pVoutWindow );
191     // Reparent the vout window
192     if( m_pVout )
193     {
194         if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
195             vout_Control( m_pVout, VOUT_CLOSE );
196     }
197 }
198
199
200 void VlcProc::unregisterVoutWindow( void *pVoutWindow )
201 {
202     m_handleSet.erase( pVoutWindow );
203 }
204
205
206 void VlcProc::dropVout()
207 {
208     if( m_pVout )
209     {
210         if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
211             vout_Control( m_pVout, VOUT_CLOSE );
212         m_pVout = NULL;
213     }
214 }
215
216
217 void VlcProc::manage()
218 {
219     // Did the user requested to quit vlc ?
220     if( getIntf()->b_die || getIntf()->p_vlc->b_die )
221     {
222         CmdQuit *pCmd = new CmdQuit( getIntf() );
223         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
224         pQueue->push( CmdGenericPtr( pCmd ) );
225     }
226
227     // Get the VLC variables
228     StreamTime *pTime = (StreamTime*)m_cVarTime.get();
229     VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
230     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
231     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
232     VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
233     VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
234     VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
235     VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
236
237     // Refresh audio variables
238     refreshAudio();
239
240    // Update the input
241     if( getIntf()->p_sys->p_input == NULL )
242     {
243         getIntf()->p_sys->p_input = getIntf()->p_sys->p_playlist->p_input;
244         if( getIntf()->p_sys->p_input )
245             vlc_object_yield( getIntf()->p_sys->p_input );
246     }
247     else if( getIntf()->p_sys->p_input->b_dead )
248     {
249         vlc_object_release( getIntf()->p_sys->p_input );
250         getIntf()->p_sys->p_input = NULL;
251     }
252
253     input_thread_t *pInput = getIntf()->p_sys->p_input;
254
255     if( pInput && !pInput->b_die )
256     {
257         // Refresh time variables
258         vlc_value_t pos;
259         var_Get( pInput, "position", &pos );
260         pTime->set( pos.f_float, false );
261
262         // Get the status of the playlist
263         playlist_status_t status =
264             getIntf()->p_sys->p_playlist->status.i_status;
265
266         pVarPlaying->set( status == PLAYLIST_RUNNING );
267         pVarStopped->set( status == PLAYLIST_STOPPED );
268         pVarPaused->set( status == PLAYLIST_PAUSED );
269
270         pVarSeekable->set( pos.f_float != 0.0 );
271     }
272     else
273     {
274         pVarPlaying->set( false );
275         pVarPaused->set( false );
276         pVarStopped->set( true );
277         pVarSeekable->set( false );
278         pTime->set( 0, false );
279     }
280
281     // Refresh the random variable
282     vlc_value_t val;
283     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
284     pVarRandom->set( val.b_bool != 0 );
285
286     // Refresh the loop variable
287     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
288     pVarLoop->set( val.b_bool != 0 );
289
290     // Refresh the repeat variable
291     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
292     pVarRepeat->set( val.b_bool != 0 );
293 }
294
295
296 void VlcProc::CmdManage::execute()
297 {
298     // Just forward to VlcProc
299     m_pParent->manage();
300 }
301
302
303 void VlcProc::refreshAudio()
304 {
305     char *pFilters = NULL;
306
307     // Check if the audio output has changed
308     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
309             VLC_OBJECT_AOUT, FIND_ANYWHERE );
310     if( pAout )
311     {
312         if( pAout != m_pAout )
313         {
314             // Register the equalizer callbacks
315             if( !var_AddCallback( pAout, "equalizer-bands",
316                                   onEqBandsChange, this ) &&
317                 !var_AddCallback( pAout, "equalizer-preamp",
318                                   onEqPreampChange, this ) )
319             {
320                 m_pAout = pAout;
321                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
322             }
323         }
324         // Get the audio filters
325         pFilters = var_GetString( pAout, "audio-filter" );
326         vlc_object_release( pAout );
327     }
328     else
329     {
330         // Get the audio filters
331         pFilters = config_GetPsz( getIntf(), "audio-filter" );
332     }
333
334     // Refresh sound volume
335     audio_volume_t volume;
336     aout_VolumeGet( getIntf(), &volume );
337     Volume *pVolume = (Volume*)m_cVarVolume.get();
338     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
339
340     // Set the mute variable
341     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
342     pVarMute->set( volume == 0 );
343
344     // Refresh the equalizer variable
345     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
346     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
347 }
348
349
350 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
351                            vlc_value_t oldVal, vlc_value_t newVal,
352                            void *pParam )
353 {
354     VlcProc *pThis = (VlcProc*)pParam;
355
356     // Update the stream variable
357     playlist_t *p_playlist = (playlist_t*)pObj;
358     pThis->updateStreamName(p_playlist);
359
360     // Create a playlist notify command (for old style playlist)
361     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
362     // Create a playtree notify command (for new style playtree)
363     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
364
365     // Push the command in the asynchronous command queue
366     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
367     pQueue->push( CmdGenericPtr( pCmd ) );
368     pQueue->push( CmdGenericPtr( pCmdTree ) );
369
370     return VLC_SUCCESS;
371 }
372
373
374 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
375                          vlc_value_t oldVal, vlc_value_t newVal,
376                          void *pParam )
377 {
378     if (newVal.i_int)
379     {
380         VlcProc *pThis = (VlcProc*)pParam;
381
382         // Create a raise all command
383         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
384             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
385
386         // Push the command in the asynchronous command queue
387         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
388         pQueue->push( CmdGenericPtr( pCmd ) );
389     }
390
391     return VLC_SUCCESS;
392 }
393
394
395 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
396                            vlc_value_t oldVal, vlc_value_t newVal,
397                            void *pParam )
398 {
399     VlcProc *pThis = (VlcProc*)pParam;
400
401     // Update the stream variable
402     playlist_t *p_playlist = (playlist_t*)pObj;
403     pThis->updateStreamName(p_playlist);
404
405     // Create a playlist notify command
406     // TODO: selective update
407     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
408     // Create a playtree notify command
409     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
410                                                          newVal.i_int );
411
412     // Push the command in the asynchronous command queue
413     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
414     pQueue->push( CmdGenericPtr( pCmd ) );
415     pQueue->push( CmdGenericPtr( pCmdTree ), true );
416
417     return VLC_SUCCESS;
418 }
419
420 int VlcProc::onItemAppend( 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
426     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
427                                                 playlist_add_t ) ) ;
428
429     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
430
431     CmdGenericPtr ptrTree;
432     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
433                                                              p_add );
434     ptrTree = CmdGenericPtr( pCmdTree );
435
436     // Create a playlist notify command (for old style playlist)
437     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
438
439     // Push the command in the asynchronous command queue
440     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
441     pQueue->push( CmdGenericPtr( pCmd ) );
442     pQueue->push( ptrTree , false );
443
444     return VLC_SUCCESS;
445 }
446
447 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
448                            vlc_value_t oldVal, vlc_value_t newVal,
449                            void *pParam )
450 {
451     VlcProc *pThis = (VlcProc*)pParam;
452
453     int i_id = newVal.i_int;
454
455     CmdGenericPtr ptrTree;
456     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
457                                                          i_id);
458     ptrTree = CmdGenericPtr( pCmdTree );
459
460     // Create a playlist notify command (for old style playlist)
461     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
462
463     // Push the command in the asynchronous command queue
464     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
465     pQueue->push( CmdGenericPtr( pCmd ) );
466     pQueue->push( ptrTree , false );
467
468     return VLC_SUCCESS;
469 }
470
471
472
473
474 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
475                                vlc_value_t oldVal, vlc_value_t newVal,
476                                void *pParam )
477 {
478     VlcProc *pThis = (VlcProc*)pParam;
479
480     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
481
482     // Update the stream variable
483     playlist_t *p_playlist = (playlist_t*)pObj;
484     pThis->updateStreamName(p_playlist);
485
486     // Create a playlist notify command (old style playlist)
487     // TODO: selective update
488     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
489     pQueue->push( CmdGenericPtr( pCmd ) );
490     // Create two playtree notify commands: one for old item, one for new
491     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
492                                                          oldVal.i_int );
493     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
494     pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
495     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
496
497     return VLC_SUCCESS;
498 }
499
500
501 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
502                            vlc_value_t oldVal, vlc_value_t newVal,
503                            void *pParam )
504 {
505     VlcProc *pThis = (VlcProc*)pParam;
506
507     // Create a playlist notify command
508     CmdChangeSkin *pCmd =
509         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
510
511     // Push the command in the asynchronous command queue
512     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
513     pQueue->push( CmdGenericPtr( pCmd ) );
514
515     return VLC_SUCCESS;
516 }
517
518 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
519                             vlc_value_t oldVal, vlc_value_t newVal,
520                             void *pParam )
521 {
522     VlcProc *pThis = (VlcProc*)pParam;
523     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
524
525     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
526     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
527     pQueue->push( CmdGenericPtr( pCmd ) );
528     return VLC_SUCCESS;
529 }
530
531
532 void VlcProc::updateStreamName( playlist_t *p_playlist )
533 {
534     if( p_playlist->p_input )
535     {
536         VarText &rStreamName = getStreamNameVar();
537         VarText &rStreamURI = getStreamURIVar();
538         // XXX: we should not need to access p_input->psz_source directly, a
539         // getter should be provided by VLC core
540         string name = p_playlist->p_input->input.p_item->psz_name;
541         // XXX: This should be done in VLC core, not here...
542         // Remove path information if any
543         OSFactory *pFactory = OSFactory::instance( getIntf() );
544         string::size_type pos = name.rfind( pFactory->getDirSeparator() );
545         if( pos != string::npos )
546         {
547             name = name.substr( pos + 1, name.size() - pos + 1 );
548         }
549         UString srcName( getIntf(), name.c_str() );
550         UString srcURI( getIntf(),
551                          p_playlist->p_input->input.p_item->psz_uri );
552
553         // Create commands to update the stream variables
554         CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
555         CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
556         // Push the commands in the asynchronous command queue
557         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
558         pQueue->push( CmdGenericPtr( pCmd1 ), false );
559         pQueue->push( CmdGenericPtr( pCmd2 ), false );
560     }
561 }
562
563
564 void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
565                           int *pXHint, int *pYHint,
566                           unsigned int *pWidthHint,
567                           unsigned int *pHeightHint )
568 {
569     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
570     pThis->m_pVout = pVout;
571     if( pThis->m_handleSet.empty() )
572     {
573         return NULL;
574     }
575     else
576     {
577         // Get the window handle
578         void *pWindow = *pThis->m_handleSet.begin();
579         // Post a resize vout command
580         CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
581                                                  *pWidthHint, *pHeightHint );
582         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
583         pQueue->push( CmdGenericPtr( pCmd ) );
584         return pWindow;
585     }
586 }
587
588
589 void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
590 {
591     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
592     pThis->m_pVout = NULL;
593 }
594
595
596 int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
597                             int query, va_list args )
598 {
599     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
600
601     switch( query )
602     {
603         case VOUT_SET_SIZE:
604         {
605             if( pThis->m_pVout )
606             {
607                 unsigned int i_width  = va_arg( args, unsigned int );
608                 unsigned int i_height = va_arg( args, unsigned int );
609                 if( !i_width ) i_width = pThis->m_pVout->i_window_width;
610                 if( !i_height ) i_height = pThis->m_pVout->i_window_height;
611
612                 // Post a resize vout command
613                 CmdResizeVout *pCmd =
614                     new CmdResizeVout( pThis->getIntf(), pWindow,
615                                        i_width, i_height );
616                 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
617                 pQueue->push( CmdGenericPtr( pCmd ) );
618             }
619         }
620
621         default:
622             msg_Dbg( pIntf, "control query not supported" );
623             break;
624     }
625
626     return VLC_SUCCESS;
627 }
628
629
630 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
631                               vlc_value_t oldVal, vlc_value_t newVal,
632                               void *pParam )
633 {
634     VlcProc *pThis = (VlcProc*)pParam;
635
636     // Post a set equalizer bands command
637     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
638                                              pThis->m_varEqBands,
639                                              newVal.psz_string );
640     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
641     pQueue->push( CmdGenericPtr( pCmd ) );
642
643     return VLC_SUCCESS;
644 }
645
646
647 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
648                                vlc_value_t oldVal, vlc_value_t newVal,
649                                void *pParam )
650 {
651     VlcProc *pThis = (VlcProc*)pParam;
652     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
653
654     // Post a set preamp command
655     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
656                                               (newVal.f_float + 20.0) / 40.0 );
657     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
658     pQueue->push( CmdGenericPtr( pCmd ) );
659
660     return VLC_SUCCESS;
661 }
662