]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/vlcproc.cpp
Skins: set the maximum volume to 1024, not 512
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
index cb4d631eca29fe40a95592ba86070c794113cad3..0ebde91a93cb5fea7ffa64d5d03ff280adea13f2 100644 (file)
@@ -1,11 +1,12 @@
 /*****************************************************************************
  * vlcproc.cpp
  *****************************************************************************
- * Copyright (C) 2003 the VideoLAN team
+ * Copyright (C) 2003-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teuli�e <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Erwan Tulou      <erwan10@videolan.org>
  *
  * 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
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_aout.h>
 #include <vlc_vout.h>
 #include <vlc_playlist.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"
 #include "../commands/cmd_resize.hpp"
 #include "../commands/cmd_vars.hpp"
 #include "../commands/cmd_dialogs.hpp"
+#include "../commands/cmd_update_item.hpp"
+#include "../commands/cmd_audio.hpp"
+#include "../commands/cmd_callbacks.hpp"
 #include "../utils/var_bool.hpp"
 #include <sstream>
 
+#include <assert.h>
 
 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
 {
@@ -61,17 +68,15 @@ 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;
 }
 
 
 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
-    m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
+    m_pVout( NULL ), m_pAout( NULL ), m_bEqualizer_started( false ),
+    m_cmdManage( this )
 {
     // Create a timer to poll the status of the vlc
     OSFactory *pOsFactory = OSFactory::instance( pIntf );
@@ -103,6 +108,9 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
     REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
 
+    REGISTER_VAR( m_cVarRecordable, VarBoolImpl, "vlc.canRecord" )
+    REGISTER_VAR( m_cVarRecording, VarBoolImpl, "vlc.isRecording" )
+
     /* Vout variables */
     REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
     REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
@@ -137,22 +145,32 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
     // so they must put commands in the queue and NOT do anything else
     // (X11 calls are not reentrant)
 
+#define ADD_CALLBACK( p_object, var ) \
+    var_AddCallback( p_object, var, onGenericCallback, this );
+
+    ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
+    ADD_CALLBACK( pIntf->p_libvlc, "intf-show" )
+
+    ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
+    ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
+    ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
+    ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
+
+#undef ADD_CALLBACK
+
     // Called when the playlist changes
     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",
-                     onIntfShow, this );
-    // Called when the current played item changes
-    var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
-                     onPlaylistChange, this );
+    // Called when the current input changes
+    var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
+                     onInputNew, this );
     // Called when a playlist item changed
     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
                      onItemChange, this );
@@ -162,14 +180,10 @@ 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;
+    // initialize variables refering to liblvc and playlist objects
+    init_variables();
 }
 
 
@@ -177,234 +191,69 @@ VlcProc::~VlcProc()
 {
     m_pTimer->stop();
     delete( m_pTimer );
-    if( getIntf()->p_sys->p_input )
+
+    if( m_pAout )
     {
-        vlc_object_release( getIntf()->p_sys->p_input );
+        vlc_object_release( m_pAout );
+        m_pAout = NULL;
     }
+    if( m_pVout )
+    {
+        vlc_object_release( m_pVout );
+        m_pVout = NULL;
+    }
+
+    interaction_Unregister( getIntf() );
+
+    var_DelCallback( getIntf()->p_libvlc, "volume-change",
+                     onGenericCallback, this );
+    var_DelCallback( getIntf()->p_libvlc, "intf-show",
+                     onGenericCallback, this );
 
-    // Callbacks for vout requests
-    getIntf()->pf_request_window = NULL;
-    getIntf()->pf_release_window = NULL;
-    getIntf()->pf_control_window = NULL;
+    var_DelCallback( getIntf()->p_sys->p_playlist, "item-current",
+                     onGenericCallback, this );
+    var_DelCallback( getIntf()->p_sys->p_playlist, "random",
+                     onGenericCallback, this );
+    var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
+                     onGenericCallback, this );
+    var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
+                     onGenericCallback, this );
 
     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",
-                     onIntfShow, this );
-    var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
-                     onPlaylistChange, this );
+    var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
+                     onInputNew, 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 )
+void VlcProc::manage()
 {
-    m_handleSet.insert( pVoutWindow );
-    // Reparent the vout window
-    if( m_pVout )
+    // Did the user request to quit vlc ?
+    if( !vlc_object_alive( getIntf() ) )
     {
-        if( vout_Control( m_pVout, VOUT_REPARENT, 0 ) != VLC_SUCCESS )
-            vout_Control( m_pVout, VOUT_CLOSE );
-    }
-}
-
-
-void VlcProc::unregisterVoutWindow( void *pVoutWindow )
-{
-    m_handleSet.erase( pVoutWindow );
-}
+        // Get the instance of OSFactory
+        OSFactory *pOsFactory = OSFactory::instance( getIntf() );
 
+        // Exit the main OS loop
+        pOsFactory->getOSLoop()->exit();
 
-void VlcProc::dropVout()
-{
-    if( m_pVout )
-    {
-        if( vout_Control( m_pVout, VOUT_REPARENT, 0 ) != VLC_SUCCESS )
-            vout_Control( m_pVout, VOUT_CLOSE );
-        m_pVout = NULL;
+        return;
     }
 }
 
-
-void VlcProc::manage()
-{
-    // Did the user request to quit vlc ?
-    if( intf_ShouldDie( getIntf() ) )
-    {
-        CmdQuit *pCmd = new CmdQuit( getIntf() );
-        AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd ) );
-    }
-
-    refreshPlaylist();
-    refreshAudio();
-    refreshInput();
-}
 void VlcProc::CmdManage::execute()
 {
     // Just forward to VlcProc
     m_pParent->manage();
 }
 
-void VlcProc::refreshAudio()
-{
-    char *pFilters;
-
-    // Check if the audio output has changed
-    aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
-            VLC_OBJECT_AOUT, FIND_ANYWHERE );
-    if( pAout )
-    {
-        if( pAout != m_pAout )
-        {
-            // Register the equalizer callbacks
-            if( !var_AddCallback( pAout, "equalizer-bands",
-                                  onEqBandsChange, this ) &&
-                !var_AddCallback( pAout, "equalizer-preamp",
-                                  onEqPreampChange, this ) )
-            {
-                m_pAout = pAout;
-                //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
-            }
-        }
-        // Get the audio filters
-        pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
-        vlc_object_release( pAout );
-    }
-    else
-    {
-        // Get the audio filters
-        pFilters = config_GetPsz( getIntf(), "audio-filter" );
-    }
-
-    // Refresh sound volume
-    audio_volume_t volume;
-    aout_VolumeGet( getIntf(), &volume );
-    Volume *pVolume = (Volume*)m_cVarVolume.get();
-    pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
-
-    // Set the mute variable
-    VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
-    pVarMute->set( volume == 0 );
-
-    // 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();
-
-    input_thread_t *pInput = getIntf()->p_sys->p_input;
-
-    // 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 )
-    {
-        vlc_object_release( getIntf()->p_sys->p_input );
-        getIntf()->p_sys->p_input = NULL;
-    }
-
-
-    if( pInput && !pInput->b_die )
-    {
-        // 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 = (vout_thread_t *)vlc_object_find( pInput,
-                                     VLC_OBJECT_VOUT, FIND_CHILD );
-        pVarHasVout->set( pVout != NULL );
-        if( pVout )
-        {
-            pVarFullscreen->set( pVout->b_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,
@@ -413,8 +262,7 @@ 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 playtree notify command (for new style playtree)
     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
@@ -427,40 +275,35 @@ int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
 }
 
 
-int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
-                         vlc_value_t oldVal, vlc_value_t newVal,
-                         void *pParam )
+
+int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
+                         vlc_value_t oldval, vlc_value_t newval, void *pParam )
 {
-    if (newVal.i_int)
-    {
-        VlcProc *pThis = (VlcProc*)pParam;
+    VlcProc *pThis = (VlcProc*)pParam;
+    input_thread_t *pInput = static_cast<input_thread_t*>(newval.p_address);
 
-        // Create a raise all command
-        CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
-            pThis->getIntf()->p_sys->p_theme->getWindowManager() );
-
-        // Push the command in the asynchronous command queue
-        AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-        pQueue->push( CmdGenericPtr( pCmd ) );
-    }
+    var_AddCallback( pInput, "intf-event", onGenericCallback, pThis );
+    var_AddCallback( pInput, "bit-rate", onGenericCallback, pThis );
+    var_AddCallback( pInput, "sample-rate", onGenericCallback, pThis );
+    var_AddCallback( pInput, "can-record", onGenericCallback, pThis );
 
     return VLC_SUCCESS;
 }
 
 
 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 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() );
@@ -513,29 +356,6 @@ int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
 }
 
 
-int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
-                               vlc_value_t oldVal, vlc_value_t newVal,
-                               void *pParam )
-{
-    VlcProc *pThis = (VlcProc*)pParam;
-
-    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-
-    // Update the stream variable
-    playlist_t *p_playlist = (playlist_t*)pObj;
-    pThis->updateStreamName(p_playlist);
-
-    // Create two playtree notify commands: one for old item, one for new
-    CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
-                                                         oldVal.i_int );
-    pQueue->push( CmdGenericPtr( pCmdTree ) , true );
-    pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
-    pQueue->push( CmdGenericPtr( pCmdTree ) , true );
-
-    return VLC_SUCCESS;
-}
-
-
 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
                            vlc_value_t oldVal, vlc_value_t newVal,
                            void *pParam )
@@ -567,136 +387,421 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
 }
 
 
-void VlcProc::updateStreamName( playlist_t *p_playlist )
+void VlcProc::updateStreamName()
 {
-    if( p_playlist && p_playlist->p_input )
-    {
-        // Get playlist item information
-        input_item_t *pItem = input_GetItem(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 = pItem->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(), pItem->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 );
-    }
+    // Create a update item command
+    CmdUpdateItem *pCmdItem = new CmdUpdateItem( getIntf(), getStreamNameVar(), getStreamURIVar() );
+
+    // 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 )
+{
+    VlcProc *pThis = (VlcProc*)pParam;
+
+    // Post a set equalizer bands command
+    CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
+                                             pThis->m_varEqBands,
+                                             newVal.psz_string );
+    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+    pQueue->push( CmdGenericPtr( pCmd ) );
+
+    return VLC_SUCCESS;
 }
 
 
-void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
-                          int *pXHint, int *pYHint,
-                          unsigned int *pWidthHint,
-                          unsigned int *pHeightHint )
+int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
+                               vlc_value_t oldVal, vlc_value_t newVal,
+                               void *pParam )
 {
-    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
-    if( pThis->m_handleSet.empty() )
-    {
-        return NULL;
+    VlcProc *pThis = (VlcProc*)pParam;
+    EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
+
+    // Post a set preamp command
+    CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
+                                              (newVal.f_float + 20.0) / 40.0 );
+    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+    pQueue->push( CmdGenericPtr( pCmd ) );
+
+    return VLC_SUCCESS;
+}
+
+
+int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
+                                vlc_value_t oldVal, vlc_value_t newVal,
+                                void *pParam )
+{
+    VlcProc *pThis = (VlcProc*)pParam;
+    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
+
+    CmdGeneric *pCmd = NULL;
+
+#define ADD_CALLBACK_ENTRY( var, label ) \
+    { \
+    if( strcmp( pVariable, var ) == 0 ) \
+        pCmd = new Cmd_##label( pThis->getIntf(), pObj, newVal ); \
     }
+
+    ADD_CALLBACK_ENTRY( "item-current", item_current_changed )
+    ADD_CALLBACK_ENTRY( "volume-change", volume_changed )
+
+    ADD_CALLBACK_ENTRY( "intf-event", intf_event_changed )
+    ADD_CALLBACK_ENTRY( "bit-rate", bit_rate_changed )
+    ADD_CALLBACK_ENTRY( "sample-rate", sample_rate_changed )
+    ADD_CALLBACK_ENTRY( "can-record", can_record_changed )
+
+    ADD_CALLBACK_ENTRY( "random", random_changed )
+    ADD_CALLBACK_ENTRY( "loop", loop_changed )
+    ADD_CALLBACK_ENTRY( "repeat", repeat_changed )
+
+    ADD_CALLBACK_ENTRY( "audio-filter", audio_filter_changed )
+
+    ADD_CALLBACK_ENTRY( "intf-show", intf_show_changed )
+
+#undef ADD_CALLBACK_ENTRY
+
+    if( pCmd )
+        pQueue->push( CmdGenericPtr( pCmd ), false );
     else
-    {
-        pThis->m_pVout = pVout;
-        // 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;
-    }
-}
+        msg_Err( pObj, "no Callback entry provided for %s", pVariable );
 
+    return VLC_SUCCESS;
+}
 
-void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
+void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
-    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
-    pThis->m_pVout = NULL;
+    input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
+
+    // Update the stream variable
+    updateStreamName();
+
+    // Create a playtree notify command
+    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+    CmdPlaytreeUpdate *pCmdTree =
+            new CmdPlaytreeUpdate( getIntf(), p_item->i_id );
+    pQueue->push( CmdGenericPtr( pCmdTree ) , true );
 }
 
+#define SET_BOOL(m,v)         ((VarBoolImpl*)(m).get())->set(v)
+#define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
+#define SET_TEXT(m,v)         ((VarText*)(m).get())->set(v)
+#define SET_VOLUME(m,v,b)     ((Volume*)(m).get())->set(v,b)
 
-int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
-                            int query, va_list args )
+void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
-    VlcProc *pThis = pIntf->p_sys->p_vlcProc;
+    input_thread_t* pInput = (input_thread_t*) p_obj;
+
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
+    if( !getIntf()->p_sys->p_input )
+    {
+        msg_Dbg( getIntf(), "new input %p detected", pInput );
 
-    switch( query )
+        getIntf()->p_sys->p_input = pInput;
+        vlc_object_hold( pInput );
+    }
+
+    switch( newVal.i_int )
     {
-        case VOUT_SET_SIZE:
+        case INPUT_EVENT_STATE:
+        {
+            int state = var_GetInteger( pInput, "state" );
+            SET_BOOL( m_cVarStopped, false );
+            SET_BOOL( m_cVarPlaying, state != PAUSE_S );
+            SET_BOOL( m_cVarPaused, state == PAUSE_S );
+            break;
+        }
+
+        case INPUT_EVENT_POSITION:
+        {
+            float pos = var_GetFloat( pInput, "position" );
+            SET_STREAMTIME( m_cVarTime, pos, false );
+            SET_BOOL( m_cVarSeekable, pos != 0.0 );
+            break;
+        }
+
+        case INPUT_EVENT_ES:
         {
-            if( pThis->m_pVout )
+            // Do we have audio
+            vlc_value_t audio_es;
+            var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
+                            &audio_es, NULL );
+            SET_BOOL( m_cVarHasAudio, audio_es.i_int > 0 );
+            break;
+        }
+
+        case INPUT_EVENT_VOUT:
+        {
+            vout_thread_t* pVout = input_GetVout( pInput );
+            SET_BOOL( m_cVarHasVout, pVout != NULL );
+            if( 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 ) );
+                SET_BOOL( m_cVarFullscreen,
+                                         var_GetBool( pVout, "fullscreen" ) );
+                vlc_object_release( pVout );
             }
+            break;
         }
 
+        case INPUT_EVENT_AOUT:
+        {
+            aout_instance_t* pAout = input_GetAout( pInput );
+
+            // end of input or aout reuse (nothing to do)
+            if( !pAout || pAout == m_pAout )
+            {
+                if( pAout )
+                    vlc_object_release( pAout );
+                break;
+            }
+
+            // remove previous Aout if any
+            if( m_pAout )
+            {
+                var_DelCallback( m_pAout, "audio-filter",
+                                 onGenericCallback, this );
+                if( m_bEqualizer_started )
+                {
+                    var_DelCallback( m_pAout, "equalizer-bands",
+                                     onEqBandsChange, this );
+                    var_DelCallback( m_pAout, "equalizer-preamp",
+                                     onEqPreampChange, this );
+                }
+                vlc_object_release( m_pAout );
+                m_pAout = NULL;
+                m_bEqualizer_started = false;
+            }
+
+            // New Aout (addCallbacks)
+            var_AddCallback( pAout, "audio-filter", onGenericCallback, this );
+
+            char *pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
+            bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
+            free( pFilters );
+            SET_BOOL( m_cVarEqualizer, b_equalizer );
+            if( b_equalizer )
+            {
+                var_AddCallback( pAout, "equalizer-bands",
+                              onEqBandsChange, this );
+                var_AddCallback( pAout, "equalizer-preamp",
+                              onEqPreampChange, this );
+                m_bEqualizer_started = true;
+            }
+            m_pAout = pAout;
+            break;
+        }
+
+        case INPUT_EVENT_CHAPTER:
+        {
+            vlc_value_t chapters_count;
+            var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
+                        &chapters_count, NULL );
+            SET_BOOL( m_cVarDvdActive, chapters_count.i_int > 0 );
+            break;
+        }
+
+        case INPUT_EVENT_RECORD:
+            SET_BOOL( m_cVarRecording, var_GetBool( pInput, "record" ) );
+            break;
+
+        case INPUT_EVENT_DEAD:
+            msg_Dbg( getIntf(), "end of input detected for %p", pInput );
+
+            var_DelCallback( pInput, "intf-event", onGenericCallback, this );
+            var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
+            var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
+            var_DelCallback( pInput, "can-record" , onGenericCallback, this );
+            vlc_object_release( pInput );
+            getIntf()->p_sys->p_input = NULL;
+            reset_input();
+            break;
+
         default:
-            msg_Dbg( pIntf, "control query not supported" );
             break;
     }
+}
 
-    return VLC_SUCCESS;
+void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    input_thread_t* pInput = (input_thread_t*) p_obj;
+
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
+    int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
+    SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
 }
 
+void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    input_thread_t* pInput = (input_thread_t*) p_obj;
 
-int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
-                              vlc_value_t oldVal, vlc_value_t newVal,
-                              void *pParam )
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
+    int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
+    SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
+}
+
+void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
-    VlcProc *pThis = (VlcProc*)pParam;
+    input_thread_t* pInput = (input_thread_t*) p_obj;
 
-    // Post a set equalizer bands command
-    CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
-                                             pThis->m_varEqBands,
-                                             newVal.psz_string );
-    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
 
-    return VLC_SUCCESS;
+    SET_BOOL( m_cVarRecordable, var_GetBool(  pInput, "can-record" ) );
 }
 
+void VlcProc::on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    playlist_t* pPlaylist = (playlist_t*) p_obj;
 
-int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
-                               vlc_value_t oldVal, vlc_value_t newVal,
-                               void *pParam )
+    SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
+}
+
+void VlcProc::on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
-    VlcProc *pThis = (VlcProc*)pParam;
-    EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
+    playlist_t* pPlaylist = (playlist_t*) p_obj;
 
-    // Post a set preamp command
-    CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
-                                              (newVal.f_float + 20.0) / 40.0 );
-    AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-    pQueue->push( CmdGenericPtr( pCmd ) );
+    SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
+}
 
-    return VLC_SUCCESS;
+void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    playlist_t* pPlaylist = (playlist_t*) p_obj;
+
+    SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
+}
+
+void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    (void)p_obj; (void)newVal;
+    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
+
+    audio_volume_t volume;
+    aout_VolumeGet( pPlaylist, &volume );
+    SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
+    SET_BOOL( m_cVarMute, volume == 0 );
+}
+
+void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    aout_instance_t* pAout = (aout_instance_t*) p_obj;
+
+    char *pFilters = newVal.psz_string;
+
+    bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
+    SET_BOOL( m_cVarEqualizer, b_equalizer );
+    if( b_equalizer && !m_bEqualizer_started )
+    {
+        var_AddCallback( pAout, "equalizer-bands", onEqBandsChange, this );
+        var_AddCallback( pAout, "equalizer-preamp", onEqPreampChange, this );
+        m_bEqualizer_started = true;
+    }
+}
+
+void VlcProc::on_intf_show_changed( vlc_object_t* p_obj, vlc_value_t newVal )
+{
+    (void)p_obj;
+    bool b_fullscreen = getFullscreenVar().get();
+
+    if( !b_fullscreen )
+    {
+        if( newVal.b_bool )
+        {
+            // Create a raise all command
+            CmdRaiseAll *pCmd = new CmdRaiseAll( getIntf(),
+                getIntf()->p_sys->p_theme->getWindowManager() );
+
+            // Push the command in the asynchronous command queue
+            AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+            pQueue->push( CmdGenericPtr( pCmd ) );
+        }
+    }
+    else
+    {
+        Theme* pTheme =  getIntf()->p_sys->p_theme;
+        TopWindow *pWin = pTheme->getWindowById( "fullscreenController" );
+        if( pWin )
+        {
+            bool b_visible = pWin->getVisibleVar().get();
+            AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+
+            if( !b_visible )
+            {
+               CmdShowWindow* pCmd = new CmdShowWindow( getIntf(),
+                             getIntf()->p_sys->p_theme->getWindowManager(),
+                             *pWin );
+               pQueue->push( CmdGenericPtr( pCmd ) );
+            }
+            else
+            {
+               CmdHideWindow* pCmd = new CmdHideWindow( getIntf(),
+                              getIntf()->p_sys->p_theme->getWindowManager(),
+                              *pWin );
+               pQueue->push( CmdGenericPtr( pCmd ) );
+            }
+        }
+    }
+}
+
+void VlcProc::reset_input()
+{
+    SET_BOOL( m_cVarSeekable, false );
+    SET_BOOL( m_cVarRecordable, false );
+    SET_BOOL( m_cVarRecording, false );
+    SET_BOOL( m_cVarDvdActive, false );
+    SET_BOOL( m_cVarFullscreen, false );
+    SET_BOOL( m_cVarHasAudio, false );
+    SET_BOOL( m_cVarHasVout, false );
+    SET_BOOL( m_cVarStopped, true );
+    SET_BOOL( m_cVarPlaying, false );
+    SET_BOOL( m_cVarPaused, false );
+
+    SET_STREAMTIME( m_cVarTime, 0, false );
+    SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
+    SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
+}
+
+void VlcProc::init_variables()
+{
+    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
+
+    SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
+    SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
+    SET_BOOL( m_cVarRepeat, var_GetBool( pPlaylist, "repeat" ) );
+
+    audio_volume_t volume;
+    aout_VolumeGet( pPlaylist, &volume );
+    SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
+    SET_BOOL( m_cVarMute, volume == 0 );
+
+    update_equalizer();
+}
+
+void VlcProc::update_equalizer()
+{
+
+    char *pFilters;
+    if( m_pAout )
+        pFilters = var_GetNonEmptyString( m_pAout, "audio-filter" );
+    else
+        pFilters = config_GetPsz( getIntf(), "audio-filter" );
+
+    bool b_equalizer = pFilters && strstr( pFilters, "equalizer" );
+    free( pFilters );
+
+    SET_BOOL( m_cVarEqualizer, b_equalizer );
+}
+
+void VlcProc::setFullscreenVar( bool b_fullscreen )
+{
+    SET_BOOL( m_cVarFullscreen, b_fullscreen );
 }
 
+#undef  SET_BOOL
+#undef  SET_STREAMTIME
+#undef  SET_TEXT
+#undef  SET_VOLUME