]> git.sesse.net Git - vlc/blobdiff - src/playlist/control.c
playlist: Fix a typo and an unecessary loop.
[vlc] / src / playlist / control.c
index fa2644cc162f919a501a3b478f1b173fc891ae27..0b7ae07713707971b1eba44fdb076830e928d1ee 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 );
@@ -204,14 +218,17 @@ int playlist_PreparseEnqueueItem( playlist_t *p_playlist,
 int playlist_AskForArtEnqueue( playlist_t *p_playlist,
                                input_item_t *p_item )
 {
-    int i;
-
     vlc_object_lock( p_playlist->p_fetcher );
-    for( i = 0; i < p_playlist->p_fetcher->i_waiting ; i++ );
+    if( !vlc_object_alive( p_playlist->p_fetcher ) )
+    {
+        vlc_object_unlock( p_playlist->p_fetcher );
+        return VLC_EGENERIC;
+    }
+
     vlc_gc_incref( p_item );
     INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
                  p_playlist->p_fetcher->i_waiting,
-                 i, p_item );
+                 p_playlist->p_fetcher->i_waiting, p_item );
     vlc_object_signal_unlocked( p_playlist->p_fetcher );
     vlc_object_unlock( p_playlist->p_fetcher );
     return VLC_SUCCESS;
@@ -223,7 +240,7 @@ static void PreparseEnqueueItemSub( playlist_t *p_playlist,
     int i;
     if( p_item->i_children == -1 )
     {
-        vlc_gc_incref( p_item );
+        vlc_gc_incref( p_item->p_input );
         INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
                      p_playlist->p_preparse->i_waiting,
                      p_playlist->p_preparse->i_waiting,