]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/vlcproc.cpp
cosmetic: remove nullity test on free() and delete
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
index 596fb16856359b59480240696c83ec14cca24672..6dc6eff2b49bf384bf959d7a58e89a3726f4336b 100644 (file)
@@ -1,11 +1,11 @@
 /*****************************************************************************
  * vlcproc.cpp
  *****************************************************************************
- * Copyright (C) 2003 the VideoLAN team
+ * Copyright (C) 2003-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulie <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <vlc/aout.h>
-#include <vlc/vout.h>
-#include <aout_internal.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_aout.h>
+#include <vlc_vout.h>
+#include <vlc_playlist.h>
+#include <vlc_window.h>
 
 #include "vlcproc.hpp"
 #include "os_factory.hpp"
+#include "os_loop.hpp"
 #include "os_timer.hpp"
 #include "var_manager.hpp"
+#include "vout_manager.hpp"
 #include "theme.hpp"
 #include "window_manager.hpp"
 #include "../commands/async_queue.hpp"
@@ -39,6 +47,7 @@
 #include "../commands/cmd_resize.hpp"
 #include "../commands/cmd_vars.hpp"
 #include "../commands/cmd_dialogs.hpp"
+#include "../commands/cmd_update_item.hpp"
 #include "../utils/var_bool.hpp"
 #include <sstream>
 
@@ -56,11 +65,8 @@ VlcProc *VlcProc::instance( intf_thread_t *pIntf )
 
 void VlcProc::destroy( intf_thread_t *pIntf )
 {
-    if( pIntf->p_sys->p_vlcProc )
-    {
-        delete pIntf->p_sys->p_vlcProc;
-        pIntf->p_sys->p_vlcProc = NULL;
-    }
+    delete pIntf->p_sys->p_vlcProc;
+    pIntf->p_sys->p_vlcProc = NULL;
 }
 
 
@@ -79,9 +85,6 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
 #define REGISTER_VAR( var, type, name ) \
     var = VariablePtr( new type( getIntf() ) ); \
     pVarManager->registerVar( var, name );
-    REGISTER_VAR( m_cPlaylist, Playlist, "playlist" )
-    pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(),
-                              "playlist.slider" );
     REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
     REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
     REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
@@ -90,22 +93,37 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
                               "playtree.slider" );
     pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
     pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
-    pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
-    REGISTER_VAR( m_cVarTime, StreamTime, "time" )
-    REGISTER_VAR( m_cVarVolume, Volume, "volume" )
-    REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
+
     REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
     REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
     REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
+
+    /* Input variables */
+    pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
+    REGISTER_VAR( m_cVarTime, StreamTime, "time" )
     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
+    REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
+
+    /* Vout variables */
+    REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
+    REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
+
+    /* Aout variables */
+    REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
+    REGISTER_VAR( m_cVarVolume, Volume, "volume" )
+    REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
     REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
     REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
-    REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
+
 #undef REGISTER_VAR
     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
     pVarManager->registerVar( m_cVarStreamName, "streamName" );
     m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
+    m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
+    pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
+    m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
+    pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
 
     // Register the equalizer bands
     for( int i = 0; i < EqualizerBands::kNbBands; i++)
@@ -124,17 +142,17 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
                      onIntfChange, this );
     // Called when a playlist item is added
-    var_AddCallback( pIntf->p_sys->p_playlist, "item-append",
+    var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
                      onItemAppend, this );
     // Called when a playlist item is deleted
     // TODO: properly handle item-deleted
-    var_AddCallback( pIntf->p_sys->p_playlist, "item-deleted",
+    var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
                      onItemDelete, this );
     // Called when the "interface shower" wants us to show the skin
-    var_AddCallback( pIntf->p_sys->p_playlist, "intf-show",
+    var_AddCallback( pIntf->p_libvlc, "intf-show",
                      onIntfShow, this );
     // Called when the current played item changes
-    var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
+    var_AddCallback( pIntf->p_sys->p_playlist, "item-current",
                      onPlaylistChange, this );
     // Called when a playlist item changed
     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
@@ -145,12 +163,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     // Called when we have an interaction dialog to display
     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
     var_AddCallback( pIntf, "interaction", onInteraction, this );
-    pIntf->b_interaction = VLC_TRUE;
-
-    // Callbacks for vout requests
-    getIntf()->pf_request_window = &getWindow;
-    getIntf()->pf_release_window = &releaseWindow;
-    getIntf()->pf_control_window = &controlWindow;
+    interaction_Register( pIntf );
 
     getIntf()->p_sys->p_input = NULL;
 }
@@ -163,155 +176,55 @@ VlcProc::~VlcProc()
     if( getIntf()->p_sys->p_input )
     {
         vlc_object_release( getIntf()->p_sys->p_input );
+        getIntf()->p_sys->p_input = NULL;
     }
 
-    // Callbacks for vout requests
-    getIntf()->pf_request_window = NULL;
-    getIntf()->pf_release_window = NULL;
-    getIntf()->pf_control_window = NULL;
+    interaction_Unregister( getIntf() );
 
     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
                      onIntfChange, this );
-    var_DelCallback( getIntf()->p_sys->p_playlist, "item-append",
+    var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
                      onItemAppend, this );
-    var_DelCallback( getIntf()->p_sys->p_playlist, "item-deleted",
+    var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
                      onItemDelete, this );
-    var_DelCallback( getIntf()->p_sys->p_playlist, "intf-show",
+    var_DelCallback( getIntf()->p_libvlc, "intf-show",
                      onIntfShow, this );
-    var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
+    var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
                      onPlaylistChange, this );
     var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
                      onItemChange, this );
     var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
+    var_DelCallback( getIntf(), "interaction", onInteraction, this );
 }
 
-
-void VlcProc::registerVoutWindow( void *pVoutWindow )
-{
-    m_handleSet.insert( pVoutWindow );
-    // Reparent the vout window
-    if( m_pVout )
-    {
-        if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
-            vout_Control( m_pVout, VOUT_CLOSE );
-    }
-}
-
-
-void VlcProc::unregisterVoutWindow( void *pVoutWindow )
-{
-    m_handleSet.erase( pVoutWindow );
-}
-
-
-void VlcProc::dropVout()
-{
-    if( m_pVout )
-    {
-        if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
-            vout_Control( m_pVout, VOUT_CLOSE );
-        m_pVout = NULL;
-    }
-}
-
-
 void VlcProc::manage()
 {
-    // Did the user requested to quit vlc ?
-    if( getIntf()->b_die || getIntf()->p_vlc->b_die )
-    {
-        CmdQuit *pCmd = new CmdQuit( getIntf() );
-        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd ) );
-    }
-
-    // Get the VLC variables
-    StreamTime *pTime = (StreamTime*)m_cVarTime.get();
-    VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
-    VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
-    VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
-    VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
-    VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
-    VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
-    VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
-    VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
-
-    // Refresh audio variables
-    refreshAudio();
-
-   // Update the input
-    if( getIntf()->p_sys->p_input == NULL )
-    {
-        getIntf()->p_sys->p_input = getIntf()->p_sys->p_playlist->p_input;
-        if( getIntf()->p_sys->p_input )
-            vlc_object_yield( getIntf()->p_sys->p_input );
-    }
-    else if( getIntf()->p_sys->p_input->b_dead )
+    // Did the user request to quit vlc ?
+    if( !vlc_object_alive( getIntf() ) )
     {
-        vlc_object_release( getIntf()->p_sys->p_input );
-        getIntf()->p_sys->p_input = NULL;
-    }
+        // Get the instance of OSFactory
+        OSFactory *pOsFactory = OSFactory::instance( getIntf() );
 
-    input_thread_t *pInput = getIntf()->p_sys->p_input;
-
-    if( pInput && !pInput->b_die )
-    {
-        // Refresh time variables
-        vlc_value_t pos;
-        var_Get( pInput, "position", &pos );
-        pTime->set( pos.f_float, false );
+        // Exit the main OS loop
+        pOsFactory->getOSLoop()->exit();
 
-        // Get the status of the playlist
-        playlist_status_t status =
-            getIntf()->p_sys->p_playlist->status.i_status;
-
-        pVarPlaying->set( status == PLAYLIST_RUNNING );
-        pVarStopped->set( status == PLAYLIST_STOPPED );
-        pVarPaused->set( status == PLAYLIST_PAUSED );
-
-        pVarSeekable->set( pos.f_float != 0.0 );
-
-        // Refresh DVD detection
-        vlc_value_t chapters_count;
-        var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
-                    &chapters_count, NULL );
-        pVarDvdActive->set( chapters_count.i_int > 0 );
+        return;
     }
-    else
-    {
-        pVarPlaying->set( false );
-        pVarPaused->set( false );
-        pVarStopped->set( true );
-        pVarSeekable->set( false );
-        pVarDvdActive->set( false );
-        pTime->set( 0, false );
-    }
-
-    // Refresh the random variable
-    vlc_value_t val;
-    var_Get( getIntf()->p_sys->p_playlist, "random", &val );
-    pVarRandom->set( val.b_bool != 0 );
-
-    // Refresh the loop variable
-    var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
-    pVarLoop->set( val.b_bool != 0 );
 
-    // Refresh the repeat variable
-    var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
-    pVarRepeat->set( val.b_bool != 0 );
+    refreshPlaylist();
+    refreshAudio();
+    refreshInput();
 }
 
-
 void VlcProc::CmdManage::execute()
 {
     // Just forward to VlcProc
     m_pParent->manage();
 }
 
-
 void VlcProc::refreshAudio()
 {
-    char *pFilters = NULL;
+    char *pFilters;
 
     // Check if the audio output has changed
     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
@@ -331,7 +244,7 @@ void VlcProc::refreshAudio()
             }
         }
         // Get the audio filters
-        pFilters = var_GetString( pAout, "audio-filter" );
+        pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
         vlc_object_release( pAout );
     }
     else
@@ -342,7 +255,7 @@ void VlcProc::refreshAudio()
 
     // Refresh sound volume
     audio_volume_t volume;
-    aout_VolumeGet( getIntf(), &volume );
+    aout_VolumeGet( getIntf()->p_sys->p_playlist, &volume );
     Volume *pVolume = (Volume*)m_cVarVolume.get();
     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
 
@@ -353,8 +266,112 @@ void VlcProc::refreshAudio()
     // Refresh the equalizer variable
     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
+    free( pFilters );
 }
 
+void VlcProc::refreshPlaylist()
+{
+    // Refresh the random variable
+    VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
+    vlc_value_t val;
+    var_Get( getIntf()->p_sys->p_playlist, "random", &val );
+    pVarRandom->set( val.b_bool != 0 );
+
+    // Refresh the loop variable
+    VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
+    var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
+    pVarLoop->set( val.b_bool != 0 );
+
+    // Refresh the repeat variable
+    VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
+    var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
+    pVarRepeat->set( val.b_bool != 0 );
+}
+
+void VlcProc::refreshInput()
+{
+    StreamTime *pTime = (StreamTime*)m_cVarTime.get();
+    VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
+    VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
+    VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
+    VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
+    VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
+    VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
+    VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
+    VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
+    VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
+    VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
+
+    // Update the input
+    if( getIntf()->p_sys->p_input == NULL )
+    {
+        getIntf()->p_sys->p_input =
+            playlist_CurrentInput( getIntf()->p_sys->p_playlist );
+    }
+    else if( getIntf()->p_sys->p_input->b_dead )
+    {
+        vlc_object_release( getIntf()->p_sys->p_input );
+        getIntf()->p_sys->p_input = NULL;
+    }
+
+    input_thread_t *pInput = getIntf()->p_sys->p_input;
+
+    if( pInput && vlc_object_alive (pInput) )
+    {
+        // Refresh time variables
+        vlc_value_t pos;
+        var_Get( pInput, "position", &pos );
+        pTime->set( pos.f_float, false );
+        pVarSeekable->set( pos.f_float != 0.0 );
+
+        // Refresh DVD detection
+        vlc_value_t chapters_count;
+        var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
+                        &chapters_count, NULL );
+        pVarDvdActive->set( chapters_count.i_int > 0 );
+
+        // Get the input bitrate
+        int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
+        pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
+
+        // Get the audio sample rate
+        int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
+        pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
+
+        // Do we have audio
+        vlc_value_t audio_es;
+        var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
+                        &audio_es, NULL );
+        pVarHasAudio->set( audio_es.i_int > 0 );
+
+        // Refresh fullscreen status
+        vout_thread_t *pVout = input_GetVout( pInput );
+        pVarHasVout->set( pVout != NULL );
+        if( pVout )
+        {
+            pVarFullscreen->set( var_GetBool( pVout, "fullscreen" ) );
+            vlc_object_release( pVout );
+        }
+
+        // Refresh play/pause status
+        int state = var_GetInteger( pInput, "state" );
+        pVarStopped->set( false );
+        pVarPlaying->set( state != PAUSE_S );
+        pVarPaused->set( state == PAUSE_S );
+    }
+    else
+    {
+        pVarSeekable->set( false );
+        pVarDvdActive->set( false );
+        pTime->set( 0, false );
+        pVarFullscreen->set( false );
+        pVarHasAudio->set( false );
+        pVarHasVout->set( false );
+        pVarStopped->set( true );
+        pVarPlaying->set( false );
+        pVarPaused->set( false );
+    }
+}
 
 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
                            vlc_value_t oldVal, vlc_value_t newVal,
@@ -363,17 +380,13 @@ int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
-    // Create a playlist notify command (for old style playlist)
-    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
     // Create a playtree notify command (for new style playtree)
     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
 
     // Push the command in the asynchronous command queue
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
     pQueue->push( CmdGenericPtr( pCmdTree ) );
 
     return VLC_SUCCESS;
@@ -384,7 +397,7 @@ int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
                          vlc_value_t oldVal, vlc_value_t newVal,
                          void *pParam )
 {
-    if (newVal.i_int)
+    if (newVal.b_bool)
     {
         VlcProc *pThis = (VlcProc*)pParam;
 
@@ -402,25 +415,21 @@ int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
 
 
 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
-                           vlc_value_t oldVal, vlc_value_t newVal,
+                           vlc_value_t oldval, vlc_value_t newval,
                            void *pParam )
 {
     VlcProc *pThis = (VlcProc*)pParam;
+    input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
-    // Create a playlist notify command
-    // TODO: selective update
-    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
     // Create a playtree notify command
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
-                                                         newVal.i_int );
+                                                         p_item->i_id );
 
     // Push the command in the asynchronous command queue
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
     pQueue->push( CmdGenericPtr( pCmdTree ), true );
 
     return VLC_SUCCESS;
@@ -442,12 +451,8 @@ int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
                                                              p_add );
     ptrTree = CmdGenericPtr( pCmdTree );
 
-    // Create a playlist notify command (for old style playlist)
-    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
-
     // Push the command in the asynchronous command queue
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
     pQueue->push( ptrTree , false );
 
     return VLC_SUCCESS;
@@ -466,41 +471,34 @@ int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
                                                          i_id);
     ptrTree = CmdGenericPtr( pCmdTree );
 
-    // Create a playlist notify command (for old style playlist)
-    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
-
     // Push the command in the asynchronous command queue
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
     pQueue->push( ptrTree , false );
 
     return VLC_SUCCESS;
 }
 
 
-
-
 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
-                               vlc_value_t oldVal, vlc_value_t newVal,
+                               vlc_value_t oldval, vlc_value_t newval,
                                void *pParam )
 {
     VlcProc *pThis = (VlcProc*)pParam;
+    input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
 
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
 
     // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
+    pThis->updateStreamName();
 
-    // Create a playlist notify command (old style playlist)
-    // TODO: selective update
-    CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
     // Create two playtree notify commands: one for old item, one for new
+#if 0 /* FIXME: Heck, no! You cannot do that.
+         There is no warranty that the old item is still valid. */
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
                                                          oldVal.i_int );
     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
-    pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
+#endif
+    CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), p_item->i_id );
     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
 
     return VLC_SUCCESS;
@@ -538,104 +536,16 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
 }
 
 
-void VlcProc::updateStreamName( playlist_t *p_playlist )
-{
-    if( p_playlist->p_input )
-    {
-        VarText &rStreamName = getStreamNameVar();
-        VarText &rStreamURI = getStreamURIVar();
-        // XXX: we should not need to access p_input->psz_source directly, a
-        // getter should be provided by VLC core
-        string name = p_playlist->p_input->input.p_item->psz_name;
-        // XXX: This should be done in VLC core, not here...
-        // Remove path information if any
-        OSFactory *pFactory = OSFactory::instance( getIntf() );
-        string::size_type pos = name.rfind( pFactory->getDirSeparator() );
-        if( pos != string::npos )
-        {
-            name = name.substr( pos + 1, name.size() - pos + 1 );
-        }
-        UString srcName( getIntf(), name.c_str() );
-        UString srcURI( getIntf(),
-                         p_playlist->p_input->input.p_item->psz_uri );
-
-        // Create commands to update the stream variables
-        CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
-        CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
-        // Push the commands in the asynchronous command queue
-        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd1 ), false );
-        pQueue->push( CmdGenericPtr( pCmd2 ), false );
-    }
-}
-
-
-void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
-                          int *pXHint, int *pYHint,
-                          unsigned int *pWidthHint,
-                          unsigned int *pHeightHint )
+void VlcProc::updateStreamName()
 {
-    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
-    pThis->m_pVout = pVout;
-    if( pThis->m_handleSet.empty() )
-    {
-        return NULL;
-    }
-    else
-    {
-        // Get the window handle
-        void *pWindow = *pThis->m_handleSet.begin();
-        // Post a resize vout command
-        CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
-                                                 *pWidthHint, *pHeightHint );
-        AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd ) );
-        return pWindow;
-    }
-}
-
-
-void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
-{
-    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
-    pThis->m_pVout = NULL;
-}
-
+    // Create a update item command
+    CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
 
-int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
-                            int query, va_list args )
-{
-    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
-
-    switch( query )
-    {
-        case VOUT_SET_SIZE:
-        {
-            if( pThis->m_pVout )
-            {
-                unsigned int i_width  = va_arg( args, unsigned int );
-                unsigned int i_height = va_arg( args, unsigned int );
-                if( !i_width ) i_width = pThis->m_pVout->i_window_width;
-                if( !i_height ) i_height = pThis->m_pVout->i_window_height;
-
-                // Post a resize vout command
-                CmdResizeVout *pCmd =
-                    new CmdResizeVout( pThis->getIntf(), pWindow,
-                                       i_width, i_height );
-                AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-                pQueue->push( CmdGenericPtr( pCmd ) );
-            }
-        }
-
-        default:
-            msg_Dbg( pIntf, "control query not supported" );
-            break;
-    }
-
-    return VLC_SUCCESS;
+    // Push the command in the asynchronous command queue
+    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+    pQueue->push( CmdGenericPtr( pCmdItem ) );
 }
 
-
 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
                               vlc_value_t oldVal, vlc_value_t newVal,
                               void *pParam )