]> git.sesse.net Git - vlc/blobdiff - src/playlist/item.c
playlist: Use PL_ASSERT_LOCKED.
[vlc] / src / playlist / item.c
index 9c4d0fea03e7301346debf74f7cda1f9c2790ce8..66573c98c660b10623c8f3e409d8e5dadd22a71d 100644 (file)
@@ -80,7 +80,8 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
             return;
         }
 
-        b_play = b_play && p_item_in_category == p_playlist->status.p_item;
+        b_play = b_play &&
+            p_item_in_category == get_current_status_item( p_playlist );
 
         /* If this item is already a node don't transform it */
         if( p_item_in_category->i_children == -1 )
@@ -153,26 +154,10 @@ static void uninstall_input_item_observer( playlist_item_t * p_item )
 /*****************************************************************************
  * Playlist item creation
  *****************************************************************************/
-playlist_item_t * playlist_ItemNewWithType( vlc_object_t *p_obj,
-                                            const char *psz_uri,
-                                            const char *psz_name,
-                                            int i_options,
-                                            const char *const *ppsz_options,
-                                            int i_duration, int i_type )
-{
-    input_item_t *p_input;
-    if( psz_uri == NULL ) return NULL;
-    p_input = input_ItemNewWithType( p_obj, psz_uri,
-                                     psz_name, i_options, ppsz_options,
-                                     i_duration, i_type );
-    return playlist_ItemNewFromInput( p_obj, p_input );
-}
-
-playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj,
+playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
                                               input_item_t *p_input )
 {
     DECMALLOC_NULL( p_item, playlist_item_t );
-    playlist_t *p_playlist = pl_Yield( p_obj );
 
     p_item->p_input = p_input;
     vlc_gc_incref( p_item->p_input );
@@ -187,11 +172,24 @@ playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj,
 
     install_input_item_observer( p_item );
 
-    pl_Release( p_item->p_playlist );
-
     return p_item;
 }
 
+playlist_item_t * playlist_ItemNewWithType( playlist_t *p_playlist,
+                                            const char *psz_uri,
+                                            const char *psz_name,
+                                            int i_options,
+                                            const char *const *ppsz_options,
+                                            int i_duration, int i_type )
+{
+    input_item_t *p_input;
+    if( psz_uri == NULL ) return NULL;
+    p_input = input_ItemNewWithType( VLC_OBJECT(p_playlist), psz_uri,
+                                     psz_name, i_options, ppsz_options,
+                                     i_duration, i_type );
+    return playlist_ItemNewFromInput( p_playlist, p_input );
+}
+
 /***************************************************************************
  * Playlist item destruction
  ***************************************************************************/
@@ -453,9 +451,15 @@ int playlist_BothAddInput( playlist_t *p_playlist,
     playlist_item_t *p_item_cat, *p_item_one, *p_up;
     int i_top;
     assert( p_input );
-    if( p_playlist->b_die ) return VLC_EGENERIC;
+
     if( !b_locked ) PL_LOCK;
 
+    if( !vlc_object_alive( p_playlist ) )
+    {
+        if( !b_locked ) PL_UNLOCK;
+        return VLC_EGENERIC;
+    }
+
     /* Add to category */
     p_item_cat = playlist_ItemNewFromInput( p_playlist, p_input );
     if( p_item_cat == NULL ) return VLC_ENOMEM;
@@ -596,7 +600,7 @@ playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,
                              p_playlist->p_root_onelevel, false );
         }
         p_playlist->b_reset_currently_playing = true;
-        vlc_cond_signal( &p_playlist->object_wait );
+        vlc_object_signal_unlocked( p_playlist );
         var_SetInteger( p_playlist, "item-change", p_item_in_category->
                                                         p_input->i_id );
         if( !b_locked ) PL_UNLOCK;
@@ -724,7 +728,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
     else
         i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
     p_playlist->b_reset_currently_playing = true;
-    vlc_cond_signal( &p_playlist->object_wait );
+    vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
     return i_ret;
 }
 
@@ -750,7 +754,7 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
     val.p_address = p_add;
     p_playlist->b_reset_currently_playing = true;
     if( b_signal )
-        vlc_cond_signal( &p_playlist->object_wait );
+        vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
     var_Set( p_playlist, "item-append", val );
     free( p_add );
 }
@@ -808,7 +812,7 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
         if( p_playlist->p_input )
             input_StopThread( p_playlist->p_input );
         p_playlist->request.i_status = PLAYLIST_RUNNING;
-        vlc_cond_signal( &p_playlist->object_wait );
+        vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
     }
     /* Preparse if PREPARSE or SPREPARSE & not enough meta */
     char *psz_artist = input_item_GetArtist( p_item_cat->p_input );
@@ -881,7 +885,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
         ARRAY_REMOVE( p_playlist->items, i );
 
     /* Check if it is the current item */
-    if( p_playlist->status.p_item == p_item )
+    if( get_current_status_item( p_playlist ) == p_item )
     {
         /* Hack we don't call playlist_Control for lock reasons */
         if( b_stop )
@@ -890,7 +894,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
             p_playlist->request.b_request = true;
             p_playlist->request.p_item = NULL;
             msg_Info( p_playlist, "stopping playback" );
-            vlc_cond_signal( &p_playlist->object_wait );
+            vlc_object_signal_maybe( VLC_OBJECT(p_playlist) );
         }
         b_delay_deletion = true;
     }