Fix for deletion of current item
authorClément Stenac <zorglub@videolan.org>
Sun, 27 Aug 2006 10:34:35 +0000 (10:34 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 27 Aug 2006 10:34:35 +0000 (10:34 +0000)
include/vlc_playlist.h
src/input/item.c
src/playlist/control.c
src/playlist/engine.c
src/playlist/item.c

index f49fdeb..e50fb71 100644 (file)
@@ -464,4 +464,6 @@ static inline vlc_bool_t playlist_IsEmpty( playlist_t * p_playlist )
 #define PL_DEBUG( msg, args ... ) {}
 #endif
 
+#define PLI_NAME( p ) p ? p->p_input->psz_name : "null"
+
 #endif
index 40fb6d5..0688ae0 100644 (file)
@@ -76,6 +76,7 @@ static void vlc_input_item_Destroy ( gc_object_t *p_this )
     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_obj,
                                           VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
 
+    fprintf( stderr, "Destroying %s\n", p_input->psz_name );
     vlc_input_item_Clean( p_input );
 
     if( p_playlist )
index 81802f3..f04562b 100644 (file)
@@ -327,7 +327,9 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
     /* Start the real work */
     if( p_playlist->request.b_request )
     {
-        PL_DEBUG( "processing request" );
+        PL_DEBUG( "processing request node %s item %s skip %i",
+                        PLI_NAME( p_playlist->request.p_item ),
+                        PLI_NAME( p_playlist->request.p_node ), i_skip );
         p_new = p_playlist->request.p_item;
         i_skip = p_playlist->request.i_skip;
 
index 19bd9fd..d01af13 100644 (file)
@@ -223,6 +223,7 @@ void playlist_MainLoop( playlist_t *p_playlist )
         {
             int i_activity;
             input_thread_t *p_input;
+            PL_DEBUG( "dead input" );
 
             p_input = p_playlist->p_input;
             p_playlist->p_input = NULL;
@@ -247,6 +248,8 @@ void playlist_MainLoop( playlist_t *p_playlist )
             if( p_playlist->status.p_item->i_flags
                 & PLAYLIST_REMOVE_FLAG )
             {
+                 PL_DEBUG( "%s was marked for deletion, deleting",
+                                 PLI_NAME( p_playlist->status.p_item  ) );
                  playlist_ItemDelete( p_playlist->status.p_item );
                  if( p_playlist->request.p_item == p_playlist->status.p_item )
                      p_playlist->request.p_item = NULL;
@@ -262,12 +265,13 @@ void playlist_MainLoop( playlist_t *p_playlist )
         /* This input is dying, let it do */
         else if( p_playlist->p_input->b_die )
         {
-            ;
+            PL_DEBUG( "dying input" );
         }
         /* This input has finished, ask it to die ! */
         else if( p_playlist->p_input->b_error
                   || p_playlist->p_input->b_eof )
         {
+            PL_DEBUG( "finished input" );
             input_StopThread( p_playlist->p_input );
             /* Select the next playlist item */
             PL_UNLOCK
@@ -275,7 +279,7 @@ void playlist_MainLoop( playlist_t *p_playlist )
         }
         else if( p_playlist->p_input->i_state != INIT_S )
         {
-            PL_UNLOCK
+            PL_UNLOCK;
             p_playlist->i_vout_destroyed_date =
                 ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT,
                                         p_playlist->i_vout_destroyed_date );
@@ -298,7 +302,7 @@ void playlist_MainLoop( playlist_t *p_playlist )
               ( p_playlist->request.b_request &&
                 p_playlist->request.i_status != PLAYLIST_STOPPED ) )
          {
-             msg_Dbg( p_playlist, "Starting new item" );
+             msg_Dbg( p_playlist, "starting new item" );
              stats_TimerStart( p_playlist, "Playlist walk",
                                   STATS_TIMER_PLAYLIST_WALK );
              p_item = playlist_NextItem( p_playlist );
@@ -315,10 +319,11 @@ void playlist_MainLoop( playlist_t *p_playlist )
          }
          else
          {
-             if( p_item && p_playlist->status.p_item &&
+             if( p_playlist->status.p_item &&
                  p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG )
              {
-                 playlist_ItemDelete( p_item );
+                 PL_DEBUG( "deleting item marked for deletion" );
+                 playlist_ItemDelete( p_playlist->status.p_item );
                  p_playlist->status.p_item = NULL;
              }
 
index 64127eb..fedd4cc 100644 (file)
@@ -632,7 +632,7 @@ int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
         /* Hack we don't call playlist_Control for lock reasons */
         if( b_stop )
         {
-            p_playlist->status.i_status = PLAYLIST_STOPPED;
+            p_playlist->request.i_status = PLAYLIST_STOPPED;
             p_playlist->request.b_request = VLC_TRUE;
             p_playlist->request.p_item = NULL;
             msg_Info( p_playlist, "stopping playback" );
@@ -648,7 +648,10 @@ int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
     if( b_flag == VLC_FALSE )
         playlist_ItemDelete( p_item );
     else
+    {
+        PL_DEBUG( "marking %s for further deletion", PLI_NAME( p_item ) );
         p_item->i_flags |= PLAYLIST_REMOVE_FLAG;
+    }
 
     return VLC_SUCCESS;
 }