[vlc-devel] commit: skins2: fix proccessing item-change at playlist level (Erwan Tulou )

git version control git at videolan.org
Sat Feb 13 18:30:20 CET 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sat Feb 13 18:09:58 2010 +0100| [428762fb77cc778ea5f02c9bcbc336f02b28a2f9] | committer: Erwan Tulou 

skins2: fix proccessing item-change at playlist level

it is needed to pass from input_item_t to playlist_item_t
 for this variable only (others directly provide playlist_item_t)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=428762fb77cc778ea5f02c9bcbc336f02b28a2f9
---

 modules/gui/skins2/commands/cmd_vars.cpp |   14 ++++++++++++--
 modules/gui/skins2/commands/cmd_vars.hpp |   21 ++++++++++++++++-----
 modules/gui/skins2/src/vlcproc.cpp       |    9 +--------
 3 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/modules/gui/skins2/commands/cmd_vars.cpp b/modules/gui/skins2/commands/cmd_vars.cpp
index 60129d5..b14c402 100644
--- a/modules/gui/skins2/commands/cmd_vars.cpp
+++ b/modules/gui/skins2/commands/cmd_vars.cpp
@@ -35,14 +35,24 @@ void CmdPlaytreeChanged::execute()
 
 void CmdPlaytreeUpdate::execute()
 {
-    VlcProc::instance( getIntf() )->getPlaytreeVar().onUpdateItem( m_id );
+    if( !m_pItem )
+        return;
+
+    playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
+    playlist_Lock( pPlaylist );
+    playlist_item_t* p_plItem = playlist_ItemGetByInput( pPlaylist, m_pItem );
+    int id = p_plItem ? p_plItem->i_id : 0;
+    playlist_Unlock( pPlaylist );
+
+    if( id )
+        VlcProc::instance( getIntf() )->getPlaytreeVar().onUpdateItem( id );
 }
 
 bool CmdPlaytreeUpdate::checkRemove( CmdGeneric *pQueuedCommand ) const
 {
     // We don't use RTTI - Use C-style cast
     CmdPlaytreeUpdate *pUpdateCommand = (CmdPlaytreeUpdate *)(pQueuedCommand);
-    return m_id == pUpdateCommand->m_id;
+    return m_pItem == pUpdateCommand->m_pItem;
 }
 
 
diff --git a/modules/gui/skins2/commands/cmd_vars.hpp b/modules/gui/skins2/commands/cmd_vars.hpp
index 1733fb1..c6f926e 100644
--- a/modules/gui/skins2/commands/cmd_vars.hpp
+++ b/modules/gui/skins2/commands/cmd_vars.hpp
@@ -24,6 +24,9 @@
 #ifndef CMD_VARS_HPP
 #define CMD_VARS_HPP
 
+#include <vlc_common.h>
+#include <vlc_playlist.h>
+
 #include "cmd_generic.hpp"
 #include "../utils/ustring.hpp"
 
@@ -41,9 +44,17 @@ DEFINE_COMMAND( PlaytreeChanged, "playtree changed" )
 class CmdPlaytreeUpdate: public CmdGeneric
 {
 public:
-    CmdPlaytreeUpdate( intf_thread_t *pIntf, int id ):
-        CmdGeneric( pIntf ), m_id( id ) { }
-    virtual ~CmdPlaytreeUpdate() { }
+    CmdPlaytreeUpdate( intf_thread_t *pIntf, input_item_t* pItem ):
+        CmdGeneric( pIntf ), m_pItem( pItem )
+    {
+        if( pItem )
+            vlc_gc_incref( pItem );
+    }
+    virtual ~CmdPlaytreeUpdate()
+    {
+        if( m_pItem )
+            vlc_gc_decref( m_pItem );
+    }
     virtual void execute();
     virtual string getType() const { return "playtree update"; }
 
@@ -51,8 +62,8 @@ public:
     virtual bool checkRemove( CmdGeneric * ) const;
 
 private:
-    /// Playlist item ID
-    int m_id;
+    /// input item changed
+    input_item_t* m_pItem;
 };
 
 /// Command to notify the playtree of an item append
diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index cc52532..59ad84a 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -267,24 +267,17 @@ int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
                            vlc_value_t oldval, vlc_value_t newval,
                            void *pParam )
 {
-    // TODO: FIXME
-    // Deactivated because it mixes up i_id from input_item_t
-    // and i_id from playlist_item_t
-#if 0
-
     VlcProc *pThis = (VlcProc*)pParam;
     input_item_t *p_item = static_cast<input_item_t*>(newval.p_address);
 
     // 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() );
     pQueue->push( CmdGenericPtr( pCmdTree ), true );
 
-#endif
-
     return VLC_SUCCESS;
 }
 




More information about the vlc-devel mailing list