]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.cpp
2d8abeaa7c109c4b03bf622545957fdbbec9a3f3
[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     }
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 }
198
199 #include <assert.h>
200
201 void VlcProc::registerVoutWindow( void *pVoutWindow )
202 {
203     m_handleSet.insert( pVoutWindow );
204     assert( !m_pVout );
205 }
206
207
208 void VlcProc::unregisterVoutWindow( void *pVoutWindow )
209 {
210     m_handleSet.erase( pVoutWindow );
211 }
212
213
214 void VlcProc::dropVout()
215 {
216     assert( !m_pVout );
217 }
218
219
220 void VlcProc::manage()
221 {
222     // Did the user request to quit vlc ?
223     if( !vlc_object_alive( getIntf() ) )
224     {
225         CmdQuit *pCmd = new CmdQuit( getIntf() );
226         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
227         pQueue->push( CmdGenericPtr( pCmd ) );
228     }
229
230     refreshPlaylist();
231     refreshAudio();
232     refreshInput();
233 }
234 void VlcProc::CmdManage::execute()
235 {
236     // Just forward to VlcProc
237     m_pParent->manage();
238 }
239
240 void VlcProc::refreshAudio()
241 {
242     char *pFilters;
243
244     // Check if the audio output has changed
245     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
246             VLC_OBJECT_AOUT, FIND_ANYWHERE );
247     if( pAout )
248     {
249         if( pAout != m_pAout )
250         {
251             // Register the equalizer callbacks
252             if( !var_AddCallback( pAout, "equalizer-bands",
253                                   onEqBandsChange, this ) &&
254                 !var_AddCallback( pAout, "equalizer-preamp",
255                                   onEqPreampChange, this ) )
256             {
257                 m_pAout = pAout;
258                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
259             }
260         }
261         // Get the audio filters
262         pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
263         vlc_object_release( pAout );
264     }
265     else
266     {
267         // Get the audio filters
268         pFilters = config_GetPsz( getIntf(), "audio-filter" );
269     }
270
271     // Refresh sound volume
272     audio_volume_t volume;
273     aout_VolumeGet( getIntf(), &volume );
274     Volume *pVolume = (Volume*)m_cVarVolume.get();
275     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
276
277     // Set the mute variable
278     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
279     pVarMute->set( volume == 0 );
280
281     // Refresh the equalizer variable
282     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
283     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
284     free( pFilters );
285 }
286
287 void VlcProc::refreshPlaylist()
288 {
289     // Refresh the random variable
290     VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
291     vlc_value_t val;
292     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
293     pVarRandom->set( val.b_bool != 0 );
294
295     // Refresh the loop variable
296     VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
297     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
298     pVarLoop->set( val.b_bool != 0 );
299
300     // Refresh the repeat variable
301     VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
302     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
303     pVarRepeat->set( val.b_bool != 0 );
304 }
305
306 void VlcProc::refreshInput()
307 {
308     StreamTime *pTime = (StreamTime*)m_cVarTime.get();
309     VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
310     VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
311     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
312     VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
313     VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
314     VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
315     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
316     VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
317     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
318     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
319
320     // Update the input
321     if( getIntf()->p_sys->p_input == NULL )
322     {
323         getIntf()->p_sys->p_input =
324             playlist_CurrentInput( getIntf()->p_sys->p_playlist );
325     }
326     else if( getIntf()->p_sys->p_input->b_dead )
327     {
328         vlc_object_release( getIntf()->p_sys->p_input );
329         getIntf()->p_sys->p_input = NULL;
330     }
331
332     input_thread_t *pInput = getIntf()->p_sys->p_input;
333
334     if( pInput && vlc_object_alive (pInput) )
335     {
336         // Refresh time variables
337         vlc_value_t pos;
338         var_Get( pInput, "position", &pos );
339         pTime->set( pos.f_float, false );
340         pVarSeekable->set( pos.f_float != 0.0 );
341
342         // Refresh DVD detection
343         vlc_value_t chapters_count;
344         var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
345                         &chapters_count, NULL );
346         pVarDvdActive->set( chapters_count.i_int > 0 );
347
348         // Get the input bitrate
349         int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
350         pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
351
352         // Get the audio sample rate
353         int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
354         pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
355
356         // Do we have audio
357         vlc_value_t audio_es;
358         var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
359                         &audio_es, NULL );
360         pVarHasAudio->set( audio_es.i_int > 0 );
361
362         // Refresh fullscreen status
363         vout_thread_t *pVout = input_GetVout( pInput );
364         pVarHasVout->set( pVout != NULL );
365         if( pVout )
366         {
367             pVarFullscreen->set( pVout->b_fullscreen );
368             vlc_object_release( pVout );
369         }
370
371         // Refresh play/pause status
372         int state = var_GetInteger( pInput, "state" );
373         pVarStopped->set( false );
374         pVarPlaying->set( state != PAUSE_S );
375         pVarPaused->set( state == PAUSE_S );
376     }
377     else
378     {
379         pVarSeekable->set( false );
380         pVarDvdActive->set( false );
381         pTime->set( 0, false );
382         pVarFullscreen->set( false );
383         pVarHasAudio->set( false );
384         pVarHasVout->set( false );
385         pVarStopped->set( true );
386         pVarPlaying->set( false );
387         pVarPaused->set( false );
388     }
389 }
390
391 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
392                            vlc_value_t oldVal, vlc_value_t newVal,
393                            void *pParam )
394 {
395     VlcProc *pThis = (VlcProc*)pParam;
396
397     // Update the stream variable
398     pThis->updateStreamName();
399
400     // Create a playtree notify command (for new style playtree)
401     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
402
403     // Push the command in the asynchronous command queue
404     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
405     pQueue->push( CmdGenericPtr( pCmdTree ) );
406
407     return VLC_SUCCESS;
408 }
409
410
411 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
412                          vlc_value_t oldVal, vlc_value_t newVal,
413                          void *pParam )
414 {
415     if (newVal.b_bool)
416     {
417         VlcProc *pThis = (VlcProc*)pParam;
418
419         // Create a raise all command
420         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
421             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
422
423         // Push the command in the asynchronous command queue
424         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
425         pQueue->push( CmdGenericPtr( pCmd ) );
426     }
427
428     return VLC_SUCCESS;
429 }
430
431
432 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
433                            vlc_value_t oldVal, vlc_value_t newVal,
434                            void *pParam )
435 {
436     VlcProc *pThis = (VlcProc*)pParam;
437
438     // Update the stream variable
439     pThis->updateStreamName();
440
441     // Create a playtree notify command
442     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
443                                                          newVal.i_int );
444
445     // Push the command in the asynchronous command queue
446     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
447     pQueue->push( CmdGenericPtr( pCmdTree ), true );
448
449     return VLC_SUCCESS;
450 }
451
452 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
453                            vlc_value_t oldVal, vlc_value_t newVal,
454                            void *pParam )
455 {
456     VlcProc *pThis = (VlcProc*)pParam;
457
458     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
459                                                 playlist_add_t ) ) ;
460
461     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
462
463     CmdGenericPtr ptrTree;
464     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
465                                                              p_add );
466     ptrTree = CmdGenericPtr( pCmdTree );
467
468     // Push the command in the asynchronous command queue
469     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
470     pQueue->push( ptrTree , false );
471
472     return VLC_SUCCESS;
473 }
474
475 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
476                            vlc_value_t oldVal, vlc_value_t newVal,
477                            void *pParam )
478 {
479     VlcProc *pThis = (VlcProc*)pParam;
480
481     int i_id = newVal.i_int;
482
483     CmdGenericPtr ptrTree;
484     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
485                                                          i_id);
486     ptrTree = CmdGenericPtr( pCmdTree );
487
488     // Push the command in the asynchronous command queue
489     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
490     pQueue->push( ptrTree , false );
491
492     return VLC_SUCCESS;
493 }
494
495
496 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
497                                vlc_value_t oldVal, vlc_value_t newVal,
498                                void *pParam )
499 {
500     VlcProc *pThis = (VlcProc*)pParam;
501
502     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
503
504     // Update the stream variable
505     pThis->updateStreamName();
506
507     // Create two playtree notify commands: one for old item, one for new
508     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
509                                                          oldVal.i_int );
510     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
511     pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
512     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
513
514     return VLC_SUCCESS;
515 }
516
517
518 int VlcProc::onSkinToLoad( 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
524     // Create a playlist notify command
525     CmdChangeSkin *pCmd =
526         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
527
528     // Push the command in the asynchronous command queue
529     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
530     pQueue->push( CmdGenericPtr( pCmd ) );
531
532     return VLC_SUCCESS;
533 }
534
535 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
536                             vlc_value_t oldVal, vlc_value_t newVal,
537                             void *pParam )
538 {
539     VlcProc *pThis = (VlcProc*)pParam;
540     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
541
542     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
543     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
544     pQueue->push( CmdGenericPtr( pCmd ) );
545     return VLC_SUCCESS;
546 }
547
548
549 void VlcProc::updateStreamName()
550 {
551     // Create a update item command
552     CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
553
554     // Push the command in the asynchronous command queue
555     AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
556     pQueue->push( CmdGenericPtr( pCmdItem ) );
557 }
558
559 void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
560                           int *pXHint, int *pYHint,
561                           unsigned int *pWidthHint,
562                           unsigned int *pHeightHint )
563 {
564     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
565     if( pThis->m_handleSet.empty() )
566     {
567         return NULL;
568     }
569     else
570     {
571         pThis->m_pVout = pVout;
572         // Get the window handle
573         void *pWindow = *pThis->m_handleSet.begin();
574         // Post a resize vout command
575         CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
576                                                  *pWidthHint, *pHeightHint );
577         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
578         pQueue->push( CmdGenericPtr( pCmd ) );
579         return pWindow;
580     }
581 }
582
583
584 void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
585 {
586     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
587     pThis->m_pVout = NULL;
588 }
589
590
591 int VlcProc::controlWindow( struct vout_window_t *pWnd,
592                             int query, va_list args )
593 {
594     intf_thread_t *pIntf = (intf_thread_t *)pWnd->p_private;
595     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
596
597     switch( query )
598     {
599         case VOUT_SET_SIZE:
600         {
601             if( pThis->m_pVout )
602             {
603                 unsigned int i_width  = va_arg( args, unsigned int );
604                 unsigned int i_height = va_arg( args, unsigned int );
605                 if( !i_width ) i_width = pThis->m_pVout->i_window_width;
606                 if( !i_height ) i_height = pThis->m_pVout->i_window_height;
607
608                 // Post a resize vout command
609                 CmdResizeVout *pCmd =
610                     new CmdResizeVout( pThis->getIntf(), pWnd->handle.hwnd,
611                                        i_width, i_height );
612                 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
613                 pQueue->push( CmdGenericPtr( pCmd ) );
614             }
615         }
616
617         default:
618             msg_Dbg( pWnd, "control query not supported" );
619             break;
620     }
621
622     return VLC_SUCCESS;
623 }
624
625
626 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
627                               vlc_value_t oldVal, vlc_value_t newVal,
628                               void *pParam )
629 {
630     VlcProc *pThis = (VlcProc*)pParam;
631
632     // Post a set equalizer bands command
633     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
634                                              pThis->m_varEqBands,
635                                              newVal.psz_string );
636     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
637     pQueue->push( CmdGenericPtr( pCmd ) );
638
639     return VLC_SUCCESS;
640 }
641
642
643 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
644                                vlc_value_t oldVal, vlc_value_t newVal,
645                                void *pParam )
646 {
647     VlcProc *pThis = (VlcProc*)pParam;
648     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
649
650     // Post a set preamp command
651     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
652                                               (newVal.f_float + 20.0) / 40.0 );
653     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
654     pQueue->push( CmdGenericPtr( pCmd ) );
655
656     return VLC_SUCCESS;
657 }
658