]> git.sesse.net Git - vlc/blobdiff - src/playlist/control.c
playlist: Don't accept more items when if preparser is dead.
[vlc] / src / playlist / control.c
index 2f22476c544568a8625d130c0f2091408dfb4c46..8f3e48a7be4b2bcec97ca4c13dd278bee70e83c8 100644 (file)
@@ -78,6 +78,9 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
     playlist_item_t *p_item, *p_node;
     vlc_value_t val;
 
+    if( !vlc_object_alive( p_playlist ) )
+        return VLC_EGENERIC;
+
     if( playlist_IsEmpty( p_playlist ) )
         return VLC_EGENERIC;
 
@@ -178,6 +181,11 @@ int playlist_PreparseEnqueue( playlist_t *p_playlist,
                               input_item_t *p_item )
 {
     vlc_object_lock( p_playlist->p_preparse );
+    if( !vlc_object_alive( p_playlist->p_preparse ) )
+    {
+        vlc_object_unlock( p_playlist->p_preparse );
+        return VLC_EGENERIC;
+    }
     vlc_gc_incref( p_item );
     INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
                  p_playlist->p_preparse->i_waiting,
@@ -195,6 +203,12 @@ int playlist_PreparseEnqueueItem( playlist_t *p_playlist,
 {
     vlc_object_lock( p_playlist );
     vlc_object_lock( p_playlist->p_preparse );
+    if( !vlc_object_alive( p_playlist->p_preparse ) )
+    {
+        vlc_object_unlock( p_playlist->p_preparse );
+        vlc_object_unlock( p_playlist );
+        return VLC_EGENERIC;
+    }
     PreparseEnqueueItemSub( p_playlist, p_item );
     vlc_object_unlock( p_playlist->p_preparse );
     vlc_object_unlock( p_playlist );
@@ -207,6 +221,12 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist,
     int i;
 
     vlc_object_lock( p_playlist->p_fetcher );
+    if( !vlc_object_alive( p_playlist->p_fetcher ) )
+    {
+        vlc_object_unlock( p_playlist->p_fetcher );
+        return VLC_EGENERIC;
+    }
+
     for( i = 0; i < p_playlist->p_fetcher->i_waiting ; i++ );
     vlc_gc_incref( p_item );
     INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
@@ -373,9 +393,23 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
                         PLI_NAME( p_playlist->request.p_item ),
                         PLI_NAME( p_playlist->request.p_node ), i_skip );
 
+        /* Make sure the node wasn't deleted */
+        if( p_playlist->status.p_node &&
+            p_playlist->status.p_node->i_flags & PLAYLIST_REMOVE_FLAG )
+        {
+             PL_DEBUG( "%s was marked for deletion, deleting",
+                             PLI_NAME( p_playlist->status.p_node  ) );
+             playlist_ItemDelete( p_playlist->status.p_node );
+             /* Don't attempt to reuse that node */
+             if( p_playlist->status.p_node == p_playlist->request.p_node )
+                p_playlist->request.p_node = NULL;
+             p_playlist->status.p_node = NULL;
+        }
+
         if( p_playlist->request.p_node &&
             p_playlist->request.p_node != p_playlist->status.p_node )
         {
+
             p_playlist->status.p_node = p_playlist->request.p_node;
             p_playlist->b_reset_currently_playing = true;
         }