Commit 3f8bbdd8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

playlist: playlist_NodeAddInput() asserts the playlist lock

As any function that requires a valid playlist item as parameter, the
function can only make sense with the lock already held by the caller.
parent 77207fe1
......@@ -336,7 +336,7 @@ VLC_API int playlist_DeleteFromInput( playlist_t *, input_item_t *, bool );
VLC_API int playlist_Add( playlist_t *, const char *, const char *, int, int, bool, bool );
VLC_API int playlist_AddExt( playlist_t *, const char *, const char *, int, int, mtime_t, int, const char *const *, unsigned, bool, bool );
VLC_API int playlist_AddInput( playlist_t *, input_item_t *, int, int, bool, bool );
VLC_API playlist_item_t * playlist_NodeAddInput( playlist_t *, input_item_t *, playlist_item_t *, int, int, bool );
VLC_API playlist_item_t * playlist_NodeAddInput( playlist_t *, input_item_t *, playlist_item_t *, int, int );
VLC_API int playlist_NodeAddCopy( playlist_t *, playlist_item_t *, playlist_item_t *, int );
/********************************** Item search *************************/
......
......@@ -714,7 +714,7 @@
int i_pos = (i_position == -1) ? PLAYLIST_END : i_position + i_current_offset++;
playlist_item_t *p_item = playlist_NodeAddInput(p_playlist, p_input, p_parent,
PLAYLIST_INSERT, i_pos, pl_Locked);
PLAYLIST_INSERT, i_pos);
if (!p_item)
continue;
......
......@@ -158,9 +158,9 @@ void RecentsMRL::save()
playlist_item_t *RecentsMRL::toPlaylist(int length)
{
playlist_Lock(THEPL);
vlc_playlist_locker locker(THEPL);
playlist_item_t *p_node_recent = playlist_NodeCreate(THEPL, _("Recently Played"), THEPL->p_root, PLAYLIST_END, PLAYLIST_RO_FLAG);
playlist_Unlock(THEPL);
if ( p_node_recent == NULL ) return NULL;
......@@ -170,10 +170,11 @@ playlist_item_t *RecentsMRL::toPlaylist(int length)
for (int i = 0; i < length; i++)
{
input_item_t *p_input = input_item_New(qtu(recents.at(i)), NULL);
playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, PLAYLIST_END, false);
playlist_NodeAddInput(THEPL, p_input, p_node_recent, PLAYLIST_APPEND, PLAYLIST_END);
}
return p_node_recent;
/* locker goes out of scope and node is invalidated here */
return NULL;
}
void RecentsMRL::playMRL( const QString &mrl )
......
......@@ -351,7 +351,7 @@ void Playtree::insertItems( VarTree& elem, const std::list<std::string>& files,
i_mode |= PLAYLIST_GO;
playlist_NodeAddInput( m_pPlaylist, pItem, p_node,
i_mode, i_pos, pl_Locked );
i_mode, i_pos );
}
fin:
......
......@@ -474,31 +474,24 @@ int playlist_AddInput( playlist_t* p_playlist, input_item_t *p_input,
* \param i_pos the position in the playlist where to add. If this is
* PLAYLIST_END the item will be added at the end of the playlist
* regardless of its size
* \param b_locked TRUE if the playlist is locked
* \return the new playlist item
*/
playlist_item_t * playlist_NodeAddInput( playlist_t *p_playlist,
input_item_t *p_input,
playlist_item_t *p_parent,
int i_mode, int i_pos,
bool b_locked )
int i_mode, int i_pos )
{
playlist_item_t *p_item;
PL_ASSERT_LOCKED;
assert( p_input );
assert( p_parent && p_parent->i_children != -1 );
PL_LOCK_IF( !b_locked );
p_item = playlist_ItemNewFromInput( p_playlist, p_input );
if( p_item == NULL )
goto end;
AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
GoAndPreparse( p_playlist, i_mode, p_item );
end:
PL_UNLOCK_IF( !b_locked );
playlist_item_t *p_item = playlist_ItemNewFromInput( p_playlist, p_input );
if( likely(p_item != NULL) )
{
AddItem( p_playlist, p_item, p_parent, i_mode, i_pos );
GoAndPreparse( p_playlist, i_mode, p_item );
}
return p_item;
}
......@@ -819,10 +812,9 @@ static int RecursiveAddIntoParent (
if( !(b_flat && b_children) )
{
p_new_item = playlist_NodeAddInput( p_playlist,
p_child_node->p_item,
p_parent,
PLAYLIST_INSERT, i_pos,
pl_Locked );
p_child_node->p_item,
p_parent,
PLAYLIST_INSERT, i_pos );
if( !p_new_item ) return i_pos;
i_pos++;
......@@ -872,7 +864,7 @@ static int RecursiveInsertCopy (
{
p_new_item = playlist_NodeAddInput( p_playlist, p_new_input,
p_parent, PLAYLIST_INSERT,
i_pos, pl_Locked );
i_pos );
vlc_gc_decref( p_new_input );
}
}
......
......@@ -180,7 +180,7 @@ static void playlist_sd_item_added(services_discovery_t *sd,
}
playlist_NodeAddInput(playlist, p_input, parent,
PLAYLIST_APPEND, PLAYLIST_END, pl_Locked);
PLAYLIST_APPEND, PLAYLIST_END);
playlist_Unlock(playlist);
}
......
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