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