]> git.sesse.net Git - vlc/commitdiff
* Fixed autodelete
authorClément Stenac <zorglub@videolan.org>
Sun, 7 Nov 2004 10:43:52 +0000 (10:43 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 7 Nov 2004 10:43:52 +0000 (10:43 +0000)
* Autodelete items played by the SDP demuxer
* Added playlist_CopyParents facility, for modules that use ItemToNode

TODO
include/vlc_playlist.h
modules/access/directory.c
modules/misc/sap.c
src/playlist/item.c
src/playlist/playlist.c

diff --git a/TODO b/TODO
index 5f6bdf09aa7a5e8e5a75630c7f673075cf7c04bc..7a89b09b20a987c613af5ef6851751e60d9f5889 100644 (file)
--- a/TODO
+++ b/TODO
@@ -119,7 +119,6 @@ Todo:<br />
    - *** Improve random mode and fix loop<br />\r
    - *   "Name finder"<br />\r
    - *   "Protocol rollover" node<br />\r
-   - *** Fix autodeletion<br />\r
    - *** Item moving/copying facilities<br />\r
    - *** Live directory representation<br /> \r
 - Helper modules<br />\r
@@ -632,6 +631,5 @@ Subtitle Files( .idx, .sub, .utf, .srt)<br />
 Status: Todo\r
 \r
 \r
-\r
 # Do not remove me\r
 Task\r
index ebe722c4eae182a2249f9d5403b7a7b7dcae7f86..8c04ce72e5a441ddb3488c710bfa9f4b62712960 100644 (file)
@@ -216,6 +216,7 @@ VLC_EXPORT( int,  playlist_Clear, ( playlist_t * ) );
 VLC_EXPORT( playlist_item_t* , __playlist_ItemNew, ( vlc_object_t *,const char *,const char * ) );
 VLC_EXPORT( void, playlist_ItemDelete, ( playlist_item_t * ) );
 VLC_EXPORT( void, playlist_ItemAddParent, ( playlist_item_t *, int,playlist_item_t *) );
+VLC_EXPORT( void, playlist_CopyParents, ( playlist_item_t *,playlist_item_t *) );
 /* Item informations accessors */
 VLC_EXPORT( int, playlist_ItemSetName, (playlist_item_t *,  char * ) );
 VLC_EXPORT( int, playlist_ItemSetDuration, (playlist_item_t *, mtime_t ) );
index 2dcd85ed0bffc7d5fdd1364bdd5c4d3e3bb4a3fb..85cffd1e7dbace029151e46d5efdf61698fe4314 100644 (file)
@@ -321,7 +321,6 @@ static int ReadDir( playlist_t *p_playlist,
     DIR *                       p_current_dir;
     struct dirent *             p_dir_content;
     playlist_item_t *p_node;
-    int i;
 
    /* Change the item to a node */
    if( p_parent->i_children == -1)
@@ -381,15 +380,10 @@ static int ReadDir( playlist_t *p_playlist,
                                        p_parent->pp_parents[0]->i_view,
                                        psz_uri, p_parent );
 
+                    playlist_CopyParents(  p_parent, p_node );
+
                     p_node->input.i_type = ITEM_TYPE_DIRECTORY;
-                    /* We need to declare the parents of the node as the
-                     * same of the parent's ones */
-                    for( i= 1 ; i< p_parent->i_parents; i ++ )
-                    {
-                        playlist_ItemAddParent( p_node,
-                                                p_parent->pp_parents[i]->i_view,
-                                                p_parent );
-                    }
+
                     if( ReadDir( p_playlist, psz_uri , MODE_EXPAND,
                                  pi_position, p_node ) != VLC_SUCCESS )
                     {
@@ -401,20 +395,12 @@ static int ReadDir( playlist_t *p_playlist,
             {
                 playlist_item_t *p_item = playlist_ItemNew( p_playlist,
                                 psz_uri, p_dir_content->d_name );
-                fprintf(stderr,"STARTTTTt\n");
                 playlist_NodeAddItem( p_playlist,p_item,
                                       p_parent->pp_parents[0]->i_view,
                                       p_parent,
                                       PLAYLIST_APPEND, PLAYLIST_END );
-                fprintf(stderr,"DONE\n");
-                /* We need to declare the parents of the node as the
-                 * same of the parent's ones */
-                for( i= 1 ; i< p_parent->i_parents; i ++ )
-                {
-                    playlist_ItemAddParent( p_item,
-                                            p_parent->pp_parents[i]->i_view,
-                                            p_parent );
-                }
+
+                playlist_CopyParents( p_parent, p_item );
             }
         }
         free( psz_uri );
index 464f0f29a3168b9ec7fce60a1d6b312fcd0ce79c..4e6fc85f01c6ee57880e5d9861f68e391b636d7b 100644 (file)
@@ -498,6 +498,8 @@ static int Demux( demux_t *p_demux )
    p_playlist = (playlist_t *)vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
                                                FIND_ANYWHERE );
 
+   p_playlist->status.p_item->i_flags |= PLAYLIST_DEL_FLAG;
+
    playlist_Add( p_playlist, p_sdp->psz_uri, p_sdp->psz_sessionname,
                  PLAYLIST_APPEND, PLAYLIST_END );
 
index c54e456f2be751593f1f026cddb42d967ddf7bf0..8e6045691da61b1be4fe5372779e4f497e78585b 100644 (file)
@@ -190,6 +190,21 @@ void playlist_ItemAddParent( playlist_item_t *p_item, int i_view,
    }
 }
 
+/**
+ * Copy all parents from parent to child
+ */
+void playlist_CopyParents( playlist_item_t *p_parent,
+                           playlist_item_t *p_child )
+{
+    int i=0;
+    for( i= 0 ; i< p_parent->i_parents; i ++ )
+    {
+        playlist_ItemAddParent( p_child,
+                                p_parent->pp_parents[i]->i_view,
+                                p_parent );
+    }
+}
+
 
 /**********************************************************************
  * playlist_item_t structure accessors
index bbda0104a08689ba10d33408969c12d19533f5dc..e69cf0f6ef8e4e55f44aa7fe63c500f607845621 100644 (file)
@@ -395,7 +395,7 @@ static void RunThread ( playlist_t *p_playlist )
     mtime_t    i_vout_destroyed_date = 0;
     mtime_t    i_sout_destroyed_date = 0;
 
-    playlist_item_t *p_autodelete_item = 0;
+    playlist_item_t *p_autodelete_item = NULL;
 
     /* Tell above that we're ready */
     vlc_thread_ready( p_playlist );
@@ -452,13 +452,6 @@ static void RunThread ( playlist_t *p_playlist )
                 i_vout_destroyed_date = 0;
                 i_sout_destroyed_date = 0;
 
-                /* Check for autodeletion */
-                if( p_autodelete_item )
-                {
-                    playlist_ItemDelete( p_autodelete_item );
-                    p_autodelete_item = 0;
-                }
-
                 continue;
             }
             /* This input is dying, let him do */
@@ -472,32 +465,15 @@ static void RunThread ( playlist_t *p_playlist )
             {
                 /* TODO FIXME XXX TODO FIXME XXX */
                 /* Check for autodeletion */
-                input_StopThread( p_playlist->p_input );
 
                 if( p_playlist->status.p_item->i_flags & PLAYLIST_DEL_FLAG )
                 {
-                    /* This ain't pretty but hey it works */
                     p_autodelete_item = p_playlist->status.p_item;
-                    p_playlist->status.p_item =
-                        playlist_ItemNew( p_playlist,
-                                          p_autodelete_item->input.psz_uri, 0);
-
-                    vlc_mutex_unlock( &p_playlist->object_lock );
-
-                    playlist_Delete( p_playlist,
-                                     p_playlist->status.p_item->input.i_id );
-                    p_playlist->request.i_skip = 1;
-                    p_playlist->status.i_status = PLAYLIST_RUNNING;
-
-                    vlc_mutex_lock( &p_playlist->object_lock );
-                }
-                else
-                {
-                    /* Select the next playlist item */
-                    input_StopThread( p_playlist->p_input );
-                    vlc_mutex_unlock( &p_playlist->object_lock );
-                    continue;
                 }
+                input_StopThread( p_playlist->p_input );
+                /* Select the next playlist item */
+                vlc_mutex_unlock( &p_playlist->object_lock );
+                continue;
             }
             else if( p_playlist->p_input->i_state != INIT_S )
             {
@@ -517,15 +493,32 @@ static void RunThread ( playlist_t *p_playlist )
              * Get the next item to play */
             p_item = NextItem( p_playlist );
 
+
             /* We must stop */
             if( p_item == NULL )
             {
+                if( p_autodelete_item )
+                {
+                    vlc_mutex_unlock( &p_playlist->object_lock );
+                    playlist_Delete( p_playlist,
+                                     p_autodelete_item->input.i_id );
+                    vlc_mutex_lock( &p_playlist->object_lock );
+                    p_autodelete_item = NULL;
+                }
                 p_playlist->status.i_status = PLAYLIST_STOPPED;
                 vlc_mutex_unlock( &p_playlist->object_lock );
                 continue;
             }
 
             PlayItem( p_playlist, p_item );
+
+            if( p_autodelete_item )
+            {
+                vlc_mutex_unlock( &p_playlist->object_lock );
+                playlist_Delete( p_playlist, p_autodelete_item->input.i_id );
+                vlc_mutex_lock( &p_playlist->object_lock );
+                p_autodelete_item = NULL;
+            }
         }
         else if( p_playlist->status.i_status == PLAYLIST_STOPPED )
         {