Commit 6bbc4b99 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Pass pointer rather than ID for playlist item-current

parent b9a26cf1
......@@ -255,8 +255,9 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
InputManager *im = (InputManager*)param;
input_item_t *p_item = static_cast<input_item_t *>(newval.p_address);
IMEvent *event = new IMEvent( ItemChanged_Type, newval.i_int );
IMEvent *event = new IMEvent( ItemChanged_Type, p_item->i_id );
QApplication::postEvent( im, event );
return VLC_SUCCESS;
}
......@@ -884,10 +885,18 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
im, setInput( input_thread_t * ) );
/* emit check if playlist has already started playing */
IMEvent *event = new IMEvent( ItemChanged_Type,
var_GetInteger( THEPL, "item-current" ) );
customEvent( event );
delete event;
input_thread_t *p_input = playlist_CurrentInput( THEPL );
if( p_input )
{
input_item_t *p_item = input_GetItem( p_input );
if( p_item )
{
IMEvent *event = new IMEvent( ItemChanged_Type, p_item->i_id );
customEvent( event );
delete event;
}
vlc_object_release( p_input );
}
}
MainInputManager::~MainInputManager()
......@@ -1003,11 +1012,11 @@ void MainInputManager::activatePlayQuit( bool b_exit )
/* Static callbacks for MIM */
static int PLItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
vlc_value_t oldval, vlc_value_t, void *param )
{
MainInputManager *mim = (MainInputManager*)param;
IMEvent *event = new IMEvent( ItemChanged_Type, newval.i_int );
IMEvent *event = new IMEvent( ItemChanged_Type, 0 );
QApplication::postEvent( mim, event );
return VLC_SUCCESS;
}
......
......@@ -479,6 +479,7 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
void *pParam )
{
VlcProc *pThis = (VlcProc*)pParam;
input_item_t *p_item = newval.p_address;
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
......@@ -486,10 +487,13 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
pThis->updateStreamName();
// 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
pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), p_item->i_id );
pQueue->push( CmdGenericPtr( pCmdTree ) , true );
return VLC_SUCCESS;
......
......@@ -318,7 +318,19 @@ static int vlclua_playlist_search( lua_State *L )
static int vlclua_playlist_current( lua_State *L )
{
playlist_t *p_playlist = vlclua_get_playlist_internal( L );
lua_pushinteger( L, var_GetInteger( p_playlist, "item-current" ) );
input_thread_t *p_input = playlist_CurrentInput( p_playlist );
int id = -1;
if( p_input )
{
input_item_t *p_item = input_GetItem( p_input );
if( p_item )
id = p_item->i_id;
vlc_object_release( p_input );
}
#warning Indexing input items by ID is unsafe,
lua_pushinteger( L, id );
vlclua_release_playlist_internal( p_playlist );
return 1;
}
......
......@@ -173,17 +173,17 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
playlist_t* p_playlist = (playlist_t*) p_this;
char *psz_buf = NULL;
input_thread_t *p_input;
input_item_t *p_item = newval.p_address;
bool b_is_item_current = !strcmp( "item-current", psz_var );
/* Don't update Telepathy presence each time an item has been preparsed */
if( b_is_item_current )
{ /* stores the current input item id */
p_intf->p_sys->i_id = newval.i_int;
p_intf->p_sys->i_id = p_item->i_id;
p_intf->p_sys->i_item_changes = 0;
}
else
{
input_item_t *p_item = newval.p_address;
if( p_item->i_id != p_intf->p_sys->i_id ) /* "item-change" */
return VLC_SUCCESS;
......
......@@ -279,8 +279,7 @@ static void VariablesInit( playlist_t *p_playlist )
var_Create( p_playlist, "playlist-item-append", VLC_VAR_ADDRESS );
var_Create( p_playlist, "item-current", VLC_VAR_INTEGER );
var_SetInteger( p_playlist, "item-current", -1 );
var_Create( p_playlist, "item-current", VLC_VAR_ADDRESS );
var_Create( p_playlist, "activity", VLC_VAR_INTEGER );
var_SetInteger( p_playlist, "activity", 0 );
......
......@@ -297,7 +297,7 @@ static int PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
}
PL_UNLOCK;
var_SetInteger( p_playlist, "item-current", p_input->i_id );
var_SetAddress( p_playlist, "item-current", p_input );
PL_LOCK;
return VLC_SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment