]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/vlcproc.cpp
Qt: cache "no-art" pixmap as well
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
index 926f049c2c1fe703c1a01bc2a4fbb6c8897a779c..b0981bb171c2fbab9f0825726eaf2298725e6b3c 100644 (file)
@@ -47,7 +47,6 @@
 #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"
@@ -74,9 +73,8 @@ void VlcProc::destroy( intf_thread_t *pIntf )
 
 
 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
-    m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
-    m_pVout( NULL ), m_pAout( NULL ), m_bEqualizer_started( false ),
-    m_cmdManage( this )
+    m_varEqBands( pIntf ), 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 );
@@ -148,7 +146,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
 #define ADD_CALLBACK( p_object, var ) \
     var_AddCallback( p_object, var, onGenericCallback, this );
 
-    ADD_CALLBACK( pIntf->p_libvlc, "volume-change" )
+    ADD_CALLBACK( pIntf->p_sys->p_playlist, "volume-change" )
     ADD_CALLBACK( pIntf->p_libvlc, "intf-show" )
 
     ADD_CALLBACK( pIntf->p_sys->p_playlist, "item-current" )
@@ -158,9 +156,6 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
 
 #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, "playlist-item-append",
                      onItemAppend, this );
@@ -205,7 +200,7 @@ VlcProc::~VlcProc()
 
     interaction_Unregister( getIntf() );
 
-    var_DelCallback( getIntf()->p_libvlc, "volume-change",
+    var_DelCallback( getIntf()->p_sys->p_playlist, "volume-change",
                      onGenericCallback, this );
     var_DelCallback( getIntf()->p_libvlc, "intf-show",
                      onGenericCallback, this );
@@ -219,8 +214,6 @@ VlcProc::~VlcProc()
     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, "playlist-item-append",
                      onItemAppend, this );
     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
@@ -255,27 +248,6 @@ void VlcProc::CmdManage::execute()
 }
 
 
-int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
-                           vlc_value_t oldVal, vlc_value_t newVal,
-                           void *pParam )
-{
-    VlcProc *pThis = (VlcProc*)pParam;
-
-    // Update the stream variable
-    pThis->updateStreamName();
-
-    // 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( pCmdTree ) );
-
-    return VLC_SUCCESS;
-}
-
-
-
 int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
                          vlc_value_t oldval, vlc_value_t newval, void *pParam )
 {
@@ -298,12 +270,9 @@ int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
     VlcProc *pThis = (VlcProc*)pParam;
     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
 
-    // Update the stream variable
-    pThis->updateStreamName();
-
     // Create a playtree notify command
     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
-                                                         p_item->i_id );
+                                                         p_item );
 
     // Push the command in the asynchronous command queue
     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
@@ -386,17 +355,6 @@ int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
     return VLC_SUCCESS;
 }
 
-
-void VlcProc::updateStreamName()
-{
-    // 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 )
@@ -472,24 +430,28 @@ int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
     return VLC_SUCCESS;
 }
 
+#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)
+
 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
     input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
 
-    // Update the stream variable
-    updateStreamName();
+    // Update short name
+    char *psz_name = input_item_GetName( p_item );
+    SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
+    free( psz_name );
 
-    // Create a playtree notify command
-    AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
-    CmdPlaytreeUpdate *pCmdTree =
-            new CmdPlaytreeUpdate( getIntf(), p_item->i_id );
-    pQueue->push( CmdGenericPtr( pCmdTree ) , true );
-}
+    // Update full uri
+    char *psz_uri = input_item_GetURI( p_item );
+    SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_uri ) );
+    free( psz_uri );
 
-#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)
+    // Update playtree
+    getPlaytreeVar().onUpdateCurrent( true );
+}
 
 void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
@@ -682,7 +644,7 @@ void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 
     audio_volume_t volume;
     aout_VolumeGet( pPlaylist, &volume );
-    SET_VOLUME( m_cVarVolume, (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
+    SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
     SET_BOOL( m_cVarMute, volume == 0 );
 }
 
@@ -761,8 +723,12 @@ void VlcProc::reset_input()
     SET_BOOL( m_cVarPaused, false );
 
     SET_STREAMTIME( m_cVarTime, 0, false );
+    SET_TEXT( m_cVarStreamName, UString( getIntf(), "") );
+    SET_TEXT( m_cVarStreamURI, UString( getIntf(), "") );
     SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
     SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
+
+    getPlaytreeVar().onUpdateCurrent( false );
 }
 
 void VlcProc::init_variables()
@@ -775,7 +741,7 @@ void VlcProc::init_variables()
 
     audio_volume_t volume;
     aout_VolumeGet( pPlaylist, &volume );
-    SET_VOLUME( m_cVarVolume, (double)volume * 2.0 / AOUT_VOLUME_MAX, false );
+    SET_VOLUME( m_cVarVolume, (double)volume / AOUT_VOLUME_MAX, false );
     SET_BOOL( m_cVarMute, volume == 0 );
 
     update_equalizer();