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