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;
}
#ifndef CMD_VARS_HPP
#define CMD_VARS_HPP
+#include <vlc_common.h>
+#include <vlc_playlist.h>
+
#include "cmd_generic.hpp"
#include "../utils/ustring.hpp"
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"; }
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
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;
}