]> git.sesse.net Git - vlc/commitdiff
all: remove items from pp_all_items when needed. Hopefully gives a more
authorSigmund Augdal Helberg <sigmunau@videolan.org>
Mon, 11 Apr 2005 21:53:33 +0000 (21:53 +0000)
committerSigmund Augdal Helberg <sigmunau@videolan.org>
Mon, 11 Apr 2005 21:53:33 +0000 (21:53 +0000)
stable playlist

TODO
src/playlist/item-ext.c
src/playlist/view.c

diff --git a/TODO b/TODO
index 97d27dac8712201ecf5a05d7dd31a7811aabf40c..0a3a98acc7a14f041a39ea8997ffa0be9d91fb65 100644 (file)
--- a/TODO
+++ b/TODO
@@ -138,7 +138,6 @@ Think playlist within playlist, directory structures, SAP section, TV channels l
 70% done.<br />
 Todo:<br />
 - Core support<br />
-   - *** Remove items from pp_all_items on deletion
    - *** Consider changing calls to playlist_Control into playlist_LockControl
    - *   "Name finder"<br />
    - *   "Protocol rollover" node<br />
index 1072c7776a50dcf46fff666e1bb9179d064dc4e6..99199c9865365d5cb9199f5bcc7730347ee4b6ef 100644 (file)
@@ -642,7 +642,7 @@ int playlist_Replace( playlist_t *p_playlist, playlist_item_t *p_olditem,
  */
 int playlist_Delete( playlist_t * p_playlist, int i_id )
 {
-    int             i;
+    int i, i_top, i_bottom;
 
     playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
 
@@ -652,6 +652,27 @@ int playlist_Delete( playlist_t * p_playlist, int i_id )
     }
     var_SetInteger( p_playlist, "item-deleted", i_id );
 
+    i_bottom = 0; i_top = p_playlist->i_all_size;
+    i = i_top / 2;
+    while( p_playlist->pp_all_items[i]->input.i_id != i_id &&
+           i_top > i_bottom )
+    {
+        if( p_playlist->pp_all_items[i]->input.i_id < i_id )
+        {
+            i_bottom = i + 1;
+        }
+        else
+        {
+            i_top = i - 1;
+        }
+        i = i_bottom + ( i_top - i_bottom ) / 2;
+    }
+    if( p_playlist->pp_all_items[i]->input.i_id == i_id )
+    {
+        REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i );
+    }
+
+    
     /* Check if it is the current item */
     if( p_playlist->status.p_item == p_item )
     {
index 96c0806cd4b5bd07f7b124dd6e7ee7f3aea8880b..fc0f81f0a2c996bbdeef03b80db64513faa8f5cc 100644 (file)
@@ -367,7 +367,7 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root,
 int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
                          vlc_bool_t b_delete_items, vlc_bool_t b_force )
 {
-    int i;
+    int i, i_top, i_bottom;
     if( p_root->i_children == -1 )
     {
         return VLC_EGENERIC;
@@ -399,6 +399,27 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
                                      p_root->pp_parents[i]->p_parent );
         }
         var_SetInteger( p_playlist, "item-deleted", p_root->input.i_id );
+
+        i_bottom = 0; i_top = p_playlist->i_all_size;
+        i = i_top / 2;
+        while( p_playlist->pp_all_items[i]->input.i_id != p_root->input.i_id &&
+               i_top > i_bottom )
+        {
+            if( p_playlist->pp_all_items[i]->input.i_id < p_root->input.i_id )
+            {
+                i_bottom = i + 1;
+            }
+            else
+            {
+                i_top = i - 1;
+            }
+            i = i_bottom + ( i_top - i_bottom ) / 2;
+        }
+        if( p_playlist->pp_all_items[i]->input.i_id == p_root->input.i_id )
+        {
+            REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i );
+        }
+        
         playlist_ItemDelete( p_root );
     }
     return VLC_SUCCESS;