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