]> git.sesse.net Git - vlc/commitdiff
playlist: Use PL_ASSERT_LOCKED where the playlist lock should be held.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Tue, 15 Jul 2008 10:59:27 +0000 (12:59 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Tue, 15 Jul 2008 11:21:35 +0000 (13:21 +0200)
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.

src/playlist/search.c
src/playlist/tree.c

index fc46c5671a596176fcf8f755a69eef67e8231a3b..3959e96b8b1e4a21d5b2f5433b1b7e029a9c02a9 100644 (file)
@@ -104,6 +104,7 @@ playlist_item_t * playlist_ItemGetByInputId( playlist_t *p_playlist,
                                              playlist_item_t *p_root )
 {
     int i;
+    PL_ASSERT_LOCKED;
     assert( p_root != NULL );
     for( i = 0 ; i< p_root->i_children ; i++ )
     {
@@ -168,6 +169,7 @@ static bool playlist_LiveSearchUpdateInternal( playlist_t *p_playlist,
 int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root,
                                const char *psz_string )
 {
+    PL_ASSERT_LOCKED;
     p_playlist->b_reset_currently_playing = true;
     playlist_LiveSearchUpdateInternal( p_playlist, p_root, psz_string );
     vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
index f78c8db5f12b03d83ccf70ed633c00792154510d..bda4c49709119e09340dc479e1a6fb9df0a9acc5 100644 (file)
@@ -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,
                         bool b_delete_items )
 {
+    PL_ASSERT_LOCKED;
     int i;
     if( p_root->i_children == -1 )
     {
@@ -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,
                          bool b_delete_items, bool b_force )
 {
+    PL_ASSERT_LOCKED;
     int i;
 
     if( p_root->i_children == -1 )
@@ -214,6 +216,7 @@ int playlist_NodeInsert( playlist_t *p_playlist,
                          playlist_item_t *p_parent,
                          int i_position )
 {
+    PL_ASSERT_LOCKED;
    (void)p_playlist;
    assert( p_parent && p_parent->i_children != -1 );
    if( i_position == -1 ) i_position = p_parent->i_children ;
@@ -238,6 +241,7 @@ int playlist_NodeRemoveItem( playlist_t *p_playlist,
                         playlist_item_t *p_item,
                         playlist_item_t *p_parent )
 {
+    PL_ASSERT_LOCKED;
    (void)p_playlist;
 
    for(int i= 0; i< p_parent->i_children ; i++ )
@@ -261,6 +265,7 @@ int playlist_NodeRemoveItem( playlist_t *p_playlist,
  */
 int playlist_NodeChildrenCount( playlist_t *p_playlist, playlist_item_t*p_node)
 {
+    PL_ASSERT_LOCKED;
     int i;
     int i_nb = 0;
 
@@ -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,
                                            const char *psz_search )
 {
+    playlist_t * p_playlist = p_node->p_playlist; /* For assert_locked */
+    PL_ASSERT_LOCKED;
     int i;
 
     if( p_node->i_children < 0 )
@@ -319,6 +326,7 @@ void playlist_NodesPairCreate( playlist_t *p_playlist, const char *psz_name,
                                playlist_item_t **pp_node_one,
                                bool b_for_sd )
 {
+    PL_ASSERT_LOCKED;
     *pp_node_cat = playlist_NodeCreate( p_playlist, psz_name,
                                         p_playlist->p_root_category, 0, NULL );
     *pp_node_one = playlist_NodeCreate( p_playlist, 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 *p_node )
 {
+    PL_ASSERT_LOCKED;
     int i;
     if( p_node->p_parent == p_playlist->p_root_category )
     {
@@ -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 *p_root )
 {
+    PL_ASSERT_LOCKED;
     int i;
     playlist_item_t *p_item;
     for ( i = p_root->i_children - 1; i >= 0; i-- )
@@ -423,6 +433,7 @@ playlist_item_t *playlist_GetNextLeaf( playlist_t *p_playlist,
                                        playlist_item_t *p_item,
                                        bool b_ena, bool b_unplayed )
 {
+    PL_ASSERT_LOCKED;
     playlist_item_t *p_next;
 
     assert( p_root && p_root->i_children != -1 );
@@ -464,6 +475,7 @@ playlist_item_t *playlist_GetPrevLeaf( playlist_t *p_playlist,
                                        playlist_item_t *p_item,
                                        bool b_ena, bool b_unplayed )
 {
+    PL_ASSERT_LOCKED;
     playlist_item_t *p_prev;
 
     PL_DEBUG2( "finding previous os %s within %s", PLI_NAME( p_item ),