all: remove items from pp_all_items when needed. Hopefully gives a more

stable playlist
parent 75be9a03
...@@ -138,7 +138,6 @@ Think playlist within playlist, directory structures, SAP section, TV channels l ...@@ -138,7 +138,6 @@ Think playlist within playlist, directory structures, SAP section, TV channels l
70% done.<br /> 70% done.<br />
Todo:<br /> Todo:<br />
- Core support<br /> - Core support<br />
- *** Remove items from pp_all_items on deletion
- *** Consider changing calls to playlist_Control into playlist_LockControl - *** Consider changing calls to playlist_Control into playlist_LockControl
- * "Name finder"<br /> - * "Name finder"<br />
- * "Protocol rollover" node<br /> - * "Protocol rollover" node<br />
......
...@@ -642,7 +642,7 @@ int playlist_Replace( playlist_t *p_playlist, playlist_item_t *p_olditem, ...@@ -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 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 ); 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 ) ...@@ -652,6 +652,27 @@ int playlist_Delete( playlist_t * p_playlist, int i_id )
} }
var_SetInteger( p_playlist, "item-deleted", 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 */ /* Check if it is the current item */
if( p_playlist->status.p_item == p_item ) if( p_playlist->status.p_item == p_item )
{ {
......
...@@ -367,7 +367,7 @@ int playlist_NodeEmpty( playlist_t *p_playlist, playlist_item_t *p_root, ...@@ -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, int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
vlc_bool_t b_delete_items, vlc_bool_t b_force ) 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 ) if( p_root->i_children == -1 )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -399,6 +399,27 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root, ...@@ -399,6 +399,27 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
p_root->pp_parents[i]->p_parent ); p_root->pp_parents[i]->p_parent );
} }
var_SetInteger( p_playlist, "item-deleted", p_root->input.i_id ); 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 ); playlist_ItemDelete( p_root );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment