Commit 3af47f42 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

playlist: Use PL_ASSERT_LOCKED where the playlist lock should be held.

Note, this commit may create some assert in previously working code. That does mean that this code wasn't properly working, and that it lacks a PL_LOCK. I prefer nice assert() over races.
parent 7b6ad173
...@@ -104,6 +104,7 @@ playlist_item_t * playlist_ItemGetByInputId( playlist_t *p_playlist, ...@@ -104,6 +104,7 @@ playlist_item_t * playlist_ItemGetByInputId( playlist_t *p_playlist,
playlist_item_t *p_root ) playlist_item_t *p_root )
{ {
int i; int i;
PL_ASSERT_LOCKED;
assert( p_root != NULL ); assert( p_root != NULL );
for( i = 0 ; i< p_root->i_children ; i++ ) for( i = 0 ; i< p_root->i_children ; i++ )
{ {
...@@ -168,6 +169,7 @@ static bool playlist_LiveSearchUpdateInternal( playlist_t *p_playlist, ...@@ -168,6 +169,7 @@ static bool playlist_LiveSearchUpdateInternal( playlist_t *p_playlist,
int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root, int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root,
const char *psz_string ) const char *psz_string )
{ {
PL_ASSERT_LOCKED;
p_playlist->b_reset_currently_playing = true; p_playlist->b_reset_currently_playing = true;
playlist_LiveSearchUpdateInternal( p_playlist, p_root, psz_string ); playlist_LiveSearchUpdateInternal( p_playlist, p_root, psz_string );
vlc_object_signal_maybe( VLC_OBJECT(p_playlist) ); vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
......
...@@ -98,6 +98,7 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist, ...@@ -98,6 +98,7 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root, int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
bool b_delete_items ) bool b_delete_items )
{ {
PL_ASSERT_LOCKED;
int i; int i;
if( p_root->i_children == -1 ) if( p_root->i_children == -1 )
{ {
...@@ -133,6 +134,7 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root, ...@@ -133,6 +134,7 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root, int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
bool b_delete_items, bool b_force ) bool b_delete_items, bool b_force )
{ {
PL_ASSERT_LOCKED;
int i; int i;
if( p_root->i_children == -1 ) if( p_root->i_children == -1 )
...@@ -214,6 +216,7 @@ int playlist_NodeInsert( playlist_t *p_playlist, ...@@ -214,6 +216,7 @@ int playlist_NodeInsert( playlist_t *p_playlist,
playlist_item_t *p_parent, playlist_item_t *p_parent,
int i_position ) int i_position )
{ {
PL_ASSERT_LOCKED;
(void)p_playlist; (void)p_playlist;
assert( p_parent && p_parent->i_children != -1 ); assert( p_parent && p_parent->i_children != -1 );
if( i_position == -1 ) i_position = p_parent->i_children ; if( i_position == -1 ) i_position = p_parent->i_children ;
...@@ -238,6 +241,7 @@ int playlist_NodeRemoveItem( playlist_t *p_playlist, ...@@ -238,6 +241,7 @@ int playlist_NodeRemoveItem( playlist_t *p_playlist,
playlist_item_t *p_item, playlist_item_t *p_item,
playlist_item_t *p_parent ) playlist_item_t *p_parent )
{ {
PL_ASSERT_LOCKED;
(void)p_playlist; (void)p_playlist;
for(int i= 0; i< p_parent->i_children ; i++ ) for(int i= 0; i< p_parent->i_children ; i++ )
...@@ -261,6 +265,7 @@ int playlist_NodeRemoveItem( playlist_t *p_playlist, ...@@ -261,6 +265,7 @@ int playlist_NodeRemoveItem( playlist_t *p_playlist,
*/ */
int playlist_NodeChildrenCount( playlist_t *p_playlist, playlist_item_t*p_node) int playlist_NodeChildrenCount( playlist_t *p_playlist, playlist_item_t*p_node)
{ {
PL_ASSERT_LOCKED;
int i; int i;
int i_nb = 0; int i_nb = 0;
...@@ -289,6 +294,8 @@ int playlist_NodeChildrenCount( playlist_t *p_playlist, playlist_item_t*p_node) ...@@ -289,6 +294,8 @@ int playlist_NodeChildrenCount( playlist_t *p_playlist, playlist_item_t*p_node)
playlist_item_t *playlist_ChildSearchName( playlist_item_t *p_node, playlist_item_t *playlist_ChildSearchName( playlist_item_t *p_node,
const char *psz_search ) const char *psz_search )
{ {
playlist_t * p_playlist = p_node->p_playlist; /* For assert_locked */
PL_ASSERT_LOCKED;
int i; int i;
if( p_node->i_children < 0 ) if( p_node->i_children < 0 )
...@@ -319,6 +326,7 @@ void playlist_NodesPairCreate( playlist_t *p_playlist, const char *psz_name, ...@@ -319,6 +326,7 @@ void playlist_NodesPairCreate( playlist_t *p_playlist, const char *psz_name,
playlist_item_t **pp_node_one, playlist_item_t **pp_node_one,
bool b_for_sd ) bool b_for_sd )
{ {
PL_ASSERT_LOCKED;
*pp_node_cat = playlist_NodeCreate( p_playlist, psz_name, *pp_node_cat = playlist_NodeCreate( p_playlist, psz_name,
p_playlist->p_root_category, 0, NULL ); p_playlist->p_root_category, 0, NULL );
*pp_node_one = playlist_NodeCreate( p_playlist, psz_name, *pp_node_one = playlist_NodeCreate( p_playlist, psz_name,
...@@ -340,6 +348,7 @@ void playlist_NodesPairCreate( playlist_t *p_playlist, const char *psz_name, ...@@ -340,6 +348,7 @@ void playlist_NodesPairCreate( playlist_t *p_playlist, const char *psz_name,
playlist_item_t * playlist_GetPreferredNode( playlist_t *p_playlist, playlist_item_t * playlist_GetPreferredNode( playlist_t *p_playlist,
playlist_item_t *p_node ) playlist_item_t *p_node )
{ {
PL_ASSERT_LOCKED;
int i; int i;
if( p_node->p_parent == p_playlist->p_root_category ) if( p_node->p_parent == p_playlist->p_root_category )
{ {
...@@ -373,6 +382,7 @@ playlist_item_t * playlist_GetPreferredNode( playlist_t *p_playlist, ...@@ -373,6 +382,7 @@ playlist_item_t * playlist_GetPreferredNode( playlist_t *p_playlist,
playlist_item_t *playlist_GetLastLeaf(playlist_t *p_playlist, playlist_item_t *playlist_GetLastLeaf(playlist_t *p_playlist,
playlist_item_t *p_root ) playlist_item_t *p_root )
{ {
PL_ASSERT_LOCKED;
int i; int i;
playlist_item_t *p_item; playlist_item_t *p_item;
for ( i = p_root->i_children - 1; i >= 0; i-- ) for ( i = p_root->i_children - 1; i >= 0; i-- )
...@@ -423,6 +433,7 @@ playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist, ...@@ -423,6 +433,7 @@ playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
playlist_item_t *p_item, playlist_item_t *p_item,
bool b_ena, bool b_unplayed ) bool b_ena, bool b_unplayed )
{ {
PL_ASSERT_LOCKED;
playlist_item_t *p_next; playlist_item_t *p_next;
assert( p_root && p_root->i_children != -1 ); assert( p_root && p_root->i_children != -1 );
...@@ -464,6 +475,7 @@ playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist, ...@@ -464,6 +475,7 @@ playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
playlist_item_t *p_item, playlist_item_t *p_item,
bool b_ena, bool b_unplayed ) bool b_ena, bool b_unplayed )
{ {
PL_ASSERT_LOCKED;
playlist_item_t *p_prev; playlist_item_t *p_prev;
PL_DEBUG2( "finding previous os %s within %s", PLI_NAME( p_item ), PL_DEBUG2( "finding previous os %s within %s", PLI_NAME( p_item ),
......
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