]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.cpp
ee0840c28b23e8a46bf168db16373ffc5620ba42
[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 = (input_thread_t *)vlc_object_find(
244             getIntf(), VLC_OBJECT_INPUT, FIND_ANYWHERE );
245     }
246     else if( getIntf()->p_sys->p_input->b_dead )
247     {
248         vlc_object_release( getIntf()->p_sys->p_input );
249         getIntf()->p_sys->p_input = NULL;
250     }
251
252     input_thread_t *pInput = getIntf()->p_sys->p_input;
253
254     if( pInput && !pInput->b_die )
255     {
256         // Refresh time variables
257         vlc_value_t pos;
258         var_Get( pInput, "position", &pos );
259         pTime->set( pos.f_float, false );
260
261         // Get the status of the playlist
262         playlist_status_t status =
263             getIntf()->p_sys->p_playlist->status.i_status;
264
265         pVarPlaying->set( status == PLAYLIST_RUNNING );
266         pVarStopped->set( status == PLAYLIST_STOPPED );
267         pVarPaused->set( status == PLAYLIST_PAUSED );
268
269         pVarSeekable->set( pos.f_float != 0.0 );
270     }
271     else
272     {
273         pVarPlaying->set( false );
274         pVarPaused->set( false );
275         pVarStopped->set( true );
276         pVarSeekable->set( false );
277         pTime->set( 0, false );
278     }
279
280     // Refresh the random variable
281     vlc_value_t val;
282     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
283     pVarRandom->set( val.b_bool != 0 );
284
285     // Refresh the loop variable
286     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
287     pVarLoop->set( val.b_bool != 0 );
288
289     // Refresh the repeat variable
290     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
291     pVarRepeat->set( val.b_bool != 0 );
292 }
293
294
295 void VlcProc::CmdManage::execute()
296 {
297     // Just forward to VlcProc
298     m_pParent->manage();
299 }
300
301
302 void VlcProc::refreshAudio()
303 {
304     char *pFilters = NULL;
305
306     // Check if the audio output has changed
307     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
308             VLC_OBJECT_AOUT, FIND_ANYWHERE );
309     if( pAout )
310     {
311         if( pAout != m_pAout )
312         {
313             // Register the equalizer callbacks
314             if( !var_AddCallback( pAout, "equalizer-bands",
315                                   onEqBandsChange, this ) &&
316                 !var_AddCallback( pAout, "equalizer-preamp",
317                                   onEqPreampChange, this ) )
318             {
319                 m_pAout = pAout;
320                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
321             }
322         }
323         // Get the audio filters
324         pFilters = var_GetString( pAout, "audio-filter" );
325         vlc_object_release( pAout );
326     }
327     else
328     {
329         // Get the audio filters
330         pFilters = config_GetPsz( getIntf(), "audio-filter" );
331     }
332
333     // Refresh sound volume
334     audio_volume_t volume;
335     aout_VolumeGet( getIntf(), &volume );
336     Volume *pVolume = (Volume*)m_cVarVolume.get();
337     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
338
339     // Set the mute variable
340     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
341     pVarMute->set( volume == 0 );
342
343     // Refresh the equalizer variable
344     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
345     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
346 }
347
348
349 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
350                            vlc_value_t oldVal, vlc_value_t newVal,
351                            void *pParam )
352 {
353     VlcProc *pThis = (VlcProc*)pParam;
354
355     // Update the stream variable
356     playlist_t *p_playlist = (playlist_t*)pObj;
357     pThis->updateStreamName(p_playlist);
358
359     // Create a playlist notify command (for old style playlist)
360     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
361     // Create a playtree notify command (for new style playtree)
362     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
363
364     // Push the command in the asynchronous command queue
365     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
366     pQueue->push( CmdGenericPtr( pCmd ) );
367     pQueue->push( CmdGenericPtr( pCmdTree ) );
368
369     return VLC_SUCCESS;
370 }
371
372
373 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
374                          vlc_value_t oldVal, vlc_value_t newVal,
375                          void *pParam )
376 {
377     if (newVal.i_int)
378     {
379         VlcProc *pThis = (VlcProc*)pParam;
380
381         // Create a raise all command
382         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
383             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
384
385         // Push the command in the asynchronous command queue
386         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
387         pQueue->push( CmdGenericPtr( pCmd ) );
388     }
389
390     return VLC_SUCCESS;
391 }
392
393
394 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
395                            vlc_value_t oldVal, vlc_value_t newVal,
396                            void *pParam )
397 {
398     VlcProc *pThis = (VlcProc*)pParam;
399
400     // Update the stream variable
401     playlist_t *p_playlist = (playlist_t*)pObj;
402     pThis->updateStreamName(p_playlist);
403
404     // Create a playlist notify command
405     // TODO: selective update
406     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
407     // Create a playtree notify command
408     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
409                                                          newVal.i_int );
410
411     // Push the command in the asynchronous command queue
412     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
413     pQueue->push( CmdGenericPtr( pCmd ) );
414     pQueue->push( CmdGenericPtr( pCmdTree ), true );
415
416     return VLC_SUCCESS;
417 }
418
419 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
420                            vlc_value_t oldVal, vlc_value_t newVal,
421                            void *pParam )
422 {
423     VlcProc *pThis = (VlcProc*)pParam;
424
425     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
426                                                 playlist_add_t ) ) ;
427
428     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
429
430     CmdGenericPtr ptrTree;
431     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
432                                                              p_add );
433     ptrTree = CmdGenericPtr( pCmdTree );
434
435     // Create a playlist notify command (for old style playlist)
436     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
437
438     // Push the command in the asynchronous command queue
439     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
440     pQueue->push( CmdGenericPtr( pCmd ) );
441     pQueue->push( ptrTree , false );
442
443     return VLC_SUCCESS;
444 }
445
446 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
447                            vlc_value_t oldVal, vlc_value_t newVal,
448                            void *pParam )
449 {
450     VlcProc *pThis = (VlcProc*)pParam;
451
452     int i_id = newVal.i_int;
453
454     CmdGenericPtr ptrTree;
455     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
456                                                          i_id);
457     ptrTree = CmdGenericPtr( pCmdTree );
458
459     // Create a playlist notify command (for old style playlist)
460     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
461
462     // Push the command in the asynchronous command queue
463     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
464     pQueue->push( CmdGenericPtr( pCmd ) );
465     pQueue->push( ptrTree , false );
466
467     return VLC_SUCCESS;
468 }
469
470
471
472
473 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
474                                vlc_value_t oldVal, vlc_value_t newVal,
475                                void *pParam )
476 {
477     VlcProc *pThis = (VlcProc*)pParam;
478
479     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
480
481     // Update the stream variable
482     playlist_t *p_playlist = (playlist_t*)pObj;
483     pThis->updateStreamName(p_playlist);
484
485     // Create a playlist notify command (old style playlist)
486     // TODO: selective update
487     CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
488     pQueue->push( CmdGenericPtr( pCmd ) );
489     // Create two playtree notify commands: one for old item, one for new
490     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
491                                                          oldVal.i_int );
492     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
493     pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
494     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
495
496     return VLC_SUCCESS;
497 }
498
499
500 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
501                            vlc_value_t oldVal, vlc_value_t newVal,
502                            void *pParam )
503 {
504     VlcProc *pThis = (VlcProc*)pParam;
505
506     // Create a playlist notify command
507     CmdChangeSkin *pCmd =
508         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
509
510     // Push the command in the asynchronous command queue
511     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
512     pQueue->push( CmdGenericPtr( pCmd ) );
513
514     return VLC_SUCCESS;
515 }
516
517 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
518                             vlc_value_t oldVal, vlc_value_t newVal,
519                             void *pParam )
520 {
521     VlcProc *pThis = (VlcProc*)pParam;
522     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
523
524     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
525     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
526     pQueue->push( CmdGenericPtr( pCmd ) );
527     return VLC_SUCCESS;
528 }
529
530
531 void VlcProc::updateStreamName( playlist_t *p_playlist )
532 {
533     if( p_playlist->p_input )
534     {
535         VarText &rStreamName = getStreamNameVar();
536         VarText &rStreamURI = getStreamURIVar();
537         // XXX: we should not need to access p_input->psz_source directly, a
538         // getter should be provided by VLC core
539         string name = p_playlist->p_input->input.p_item->psz_name;
540         // XXX: This should be done in VLC core, not here...
541         // Remove path information if any
542         OSFactory *pFactory = OSFactory::instance( getIntf() );
543         string::size_type pos = name.rfind( pFactory->getDirSeparator() );
544         if( pos != string::npos )
545         {
546             name = name.substr( pos + 1, name.size() - pos + 1 );
547         }
548         UString srcName( getIntf(), name.c_str() );
549         UString srcURI( getIntf(),
550                          p_playlist->p_input->input.p_item->psz_uri );
551
552         // Create commands to update the stream variables
553         CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
554         CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
555         // Push the commands in the asynchronous command queue
556         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
557         pQueue->push( CmdGenericPtr( pCmd1 ), false );
558         pQueue->push( CmdGenericPtr( pCmd2 ), false );
559     }
560 }
561
562
563 void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
564                           int *pXHint, int *pYHint,
565                           unsigned int *pWidthHint,
566                           unsigned int *pHeightHint )
567 {
568     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
569     pThis->m_pVout = pVout;
570     if( pThis->m_handleSet.empty() )
571     {
572         return NULL;
573     }
574     else
575     {
576         // Get the window handle
577         void *pWindow = *pThis->m_handleSet.begin();
578         // Post a resize vout command
579         CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
580                                                  *pWidthHint, *pHeightHint );
581         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
582         pQueue->push( CmdGenericPtr( pCmd ) );
583         return pWindow;
584     }
585 }
586
587
588 void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
589 {
590     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
591     pThis->m_pVout = NULL;
592 }
593
594
595 int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
596                             int query, va_list args )
597 {
598     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
599
600     switch( query )
601     {
602         case VOUT_SET_SIZE:
603         {
604             if( pThis->m_pVout )
605             {
606                 unsigned int i_width  = va_arg( args, unsigned int );
607                 unsigned int i_height = va_arg( args, unsigned int );
608                 if( !i_width ) i_width = pThis->m_pVout->i_window_width;
609                 if( !i_height ) i_height = pThis->m_pVout->i_window_height;
610
611                 // Post a resize vout command
612                 CmdResizeVout *pCmd =
613                     new CmdResizeVout( pThis->getIntf(), pWindow,
614                                        i_width, i_height );
615                 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
616                 pQueue->push( CmdGenericPtr( pCmd ) );
617             }
618         }
619
620         default:
621             msg_Dbg( pIntf, "control query not supported" );
622             break;
623     }
624
625     return VLC_SUCCESS;
626 }
627
628
629 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
630                               vlc_value_t oldVal, vlc_value_t newVal,
631                               void *pParam )
632 {
633     VlcProc *pThis = (VlcProc*)pParam;
634
635     // Post a set equalizer bands command
636     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
637                                              pThis->m_varEqBands,
638                                              newVal.psz_string );
639     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
640     pQueue->push( CmdGenericPtr( pCmd ) );
641
642     return VLC_SUCCESS;
643 }
644
645
646 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
647                                vlc_value_t oldVal, vlc_value_t newVal,
648                                void *pParam )
649 {
650     VlcProc *pThis = (VlcProc*)pParam;
651     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
652
653     // Post a set preamp command
654     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
655                                               (newVal.f_float + 20.0) / 40.0 );
656     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
657     pQueue->push( CmdGenericPtr( pCmd ) );
658
659     return VLC_SUCCESS;
660 }
661