Commit 2a70d841 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

lua: return playlist item ID from playlist.current()

This makes more sense than returning the input item ID, which is not
exposed in any other place and manner through Lua. And it seems that
was the intent too.

Then again, the value is either way potentially invalid by the time it
is returned.
parent 3012eb89
......@@ -312,18 +312,14 @@ 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 );
input_thread_t *p_input = playlist_CurrentInput( p_playlist );
playlist_item_t *item;
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,
PL_LOCK;
item = playlist_CurrentPlayingItem( p_playlist );
if( item != NULL )
id = item->i_id;
PL_UNLOCK;
lua_pushinteger( L, id );
return 1;
}
......
......@@ -298,7 +298,7 @@ playlist.get( [what, [tree]] ): Get the playlist.
.nb_played:
.children: A table of children playlist items.
playlist.search( name ): filter the playlist items with the given string
playlist.current(): return the current input item id
playlist.current(): return the current playlist item id
playlist.sort( key ): sort the playlist according to the key.
Key must be one of the followings values: 'id', 'title', 'title nodes first',
'artist', 'genre', 'random', 'duration',
......
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