]> git.sesse.net Git - vlc/commitdiff
Enqueue the item ID instead of pointer for preparse
authorClément Stenac <zorglub@videolan.org>
Sat, 21 Jan 2006 16:44:36 +0000 (16:44 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 21 Jan 2006 16:44:36 +0000 (16:44 +0000)
Add a PLAYLIST_PREPARSE flag to tell that the item must be enqueued for preparse on add (not implemented yet).

Refs:#192

include/vlc/vlc.h
include/vlc_playlist.h
modules/access/directory.c
src/playlist/playlist.c

index acceca8c065c1b50b4ebc8cf05f2a518160934e7..a6afd1d4b91120ba2424a4f71f8133abc764e602 100644 (file)
@@ -142,6 +142,7 @@ struct vlc_list_t
 #define PLAYLIST_APPEND          0x0004
 #define PLAYLIST_GO              0x0008
 #define PLAYLIST_CHECK_INSERT    0x0010
+#define PLAYLIST_PREPARSE        0x0020
 
 #define PLAYLIST_END           -666
 
index d2a0902dbadb219ceda64602c7f28e7ecafabd5a..5c387676f2735a8087932413b627e60397ff61e8 100644 (file)
@@ -136,7 +136,7 @@ struct playlist_preparse_t
     VLC_COMMON_MEMBERS
     vlc_mutex_t     lock;
     int             i_waiting;
-    input_item_t  **pp_waiting;
+    int            *pi_waiting;
 };
 
 
index 7ef49f982aa791e52f9da7abdfa66be6267a7072..f600040d67e26fcdf0ad2eecadae03e4f506aa54 100644 (file)
@@ -558,7 +558,8 @@ static int ReadDir( playlist_t *p_playlist, const char *psz_name,
                 playlist_NodeAddItem( p_playlist,p_item,
                                       p_parent->pp_parents[0]->i_view,
                                       p_parent,
-                                      PLAYLIST_APPEND, PLAYLIST_END );
+                                      PLAYLIST_APPEND | PLAYLIST_PREPARSE,
+                                      PLAYLIST_END );
 
                 playlist_CopyParents( p_parent, p_item );
             }
index 3e2272df4aaa8fb34b5a9be82522282eb9268b25..7a9a07b26e5fb85ad2207c17d934fb01ee99446b 100644 (file)
@@ -198,7 +198,7 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
 
     // Preparse
     p_playlist->p_preparse->i_waiting = 0;
-    p_playlist->p_preparse->pp_waiting = NULL;
+    p_playlist->p_preparse->pi_waiting = NULL;
 
     // Interaction
     p_playlist->p_interaction = NULL;
@@ -486,10 +486,10 @@ int playlist_PreparseEnqueue( playlist_t *p_playlist,
                               input_item_t *p_item )
 {
     vlc_mutex_lock( &p_playlist->p_preparse->object_lock );
-    INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
+    INSERT_ELEM( p_playlist->p_preparse->pi_waiting,
                  p_playlist->p_preparse->i_waiting,
                  p_playlist->p_preparse->i_waiting,
-                 p_item );
+                 p_item->i_id );
     vlc_mutex_unlock( &p_playlist->p_preparse->object_lock );
     return VLC_SUCCESS;
 }
@@ -501,10 +501,10 @@ void playlist_PreparseEnqueueItemSub( playlist_t *p_playlist,
     int i;
     if( p_item->i_children == -1 )
     {
-        INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
+        INSERT_ELEM( p_playlist->p_preparse->pi_waiting,
                      p_playlist->p_preparse->i_waiting,
                      p_playlist->p_preparse->i_waiting,
-                     &(p_item->input) );
+                     (p_item->input.i_id) );
     }
     else
     {
@@ -842,11 +842,22 @@ static void RunPreparse ( playlist_preparse_t *p_obj )
 
         if( p_obj->i_waiting > 0 )
         {
-            input_item_t *p_current = p_obj->pp_waiting[0];
-            REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 );
+            int i_current_id = p_obj->pi_waiting[0];
+            playlist_item_t *p_current;
+            REMOVE_ELEM( p_obj->pi_waiting, p_obj->i_waiting, 0 );
             vlc_mutex_unlock( &p_obj->object_lock );
-            input_Preparse( p_playlist, p_current );
-            var_SetInteger( p_playlist, "item-change", p_current->i_id );
+            vlc_mutex_lock( &p_playlist->object_lock );
+
+            p_current = playlist_ItemGetById( p_playlist, i_current_id );
+            if( p_current )
+            {
+                input_Preparse( p_playlist, &p_current->input );
+                vlc_mutex_unlock( &p_playlist->object_lock );
+                var_SetInteger( p_playlist, "item-change",
+                                p_current->input.i_id );
+            }
+            else
+                vlc_mutex_unlock( &p_playlist->object_lock );
             vlc_mutex_lock( &p_obj->object_lock );
         }
         b_sleep = ( p_obj->i_waiting == 0 );