Commit 2dfe5574 authored by Jakob Leben's avatar Jakob Leben

playlist: make playlist_DeleteFromInput delete container nodes as well

and refactor playlist code for optimization
parent 22b2b54f
...@@ -35,8 +35,6 @@ static void AddItem( playlist_t *p_playlist, playlist_item_t *p_item, ...@@ -35,8 +35,6 @@ static void AddItem( playlist_t *p_playlist, playlist_item_t *p_item,
static void GoAndPreparse( playlist_t *p_playlist, int i_mode, static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
playlist_item_t *, playlist_item_t * ); playlist_item_t *, playlist_item_t * );
static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item ); static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item );
static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
bool b_stop );
static playlist_item_t *ItemToNode( playlist_t *, playlist_item_t *, bool ); static playlist_item_t *ItemToNode( playlist_t *, playlist_item_t *, bool );
...@@ -239,24 +237,11 @@ int playlist_ItemRelease( playlist_item_t *p_item ) ...@@ -239,24 +237,11 @@ int playlist_ItemRelease( playlist_item_t *p_item )
static int DeleteFromInput( playlist_t *p_playlist, input_item_t *p_input, static int DeleteFromInput( playlist_t *p_playlist, input_item_t *p_input,
playlist_item_t *p_root, bool b_do_stop ) playlist_item_t *p_root, bool b_do_stop )
{ {
int i;
PL_ASSERT_LOCKED; PL_ASSERT_LOCKED;
for( i = 0 ; i< p_root->i_children ; i++ ) playlist_item_t *p_item = playlist_ItemFindFromInputAndRoot(
{ p_playlist, p_input, p_root, false );
if( p_root->pp_children[i]->i_children == -1 && if( !p_item ) return VLC_EGENERIC;
p_root->pp_children[i]->p_input == p_input ) return playlist_DeleteItem( p_playlist, p_item, b_do_stop );
{
DeleteInner( p_playlist, p_root->pp_children[i], b_do_stop );
return VLC_SUCCESS;
}
else if( p_root->pp_children[i]->i_children >= 0 )
{
int i_ret = DeleteFromInput( p_playlist, p_input,
p_root->pp_children[i], b_do_stop );
if( i_ret == VLC_SUCCESS ) return VLC_SUCCESS;
}
}
return VLC_EGENERIC;
} }
/** /**
...@@ -332,7 +317,7 @@ int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id ) ...@@ -332,7 +317,7 @@ int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
PL_ASSERT_LOCKED; PL_ASSERT_LOCKED;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id ); playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
if( !p_item ) return VLC_EGENERIC; if( !p_item ) return VLC_EGENERIC;
return DeleteInner( p_playlist, p_item, true ); return playlist_DeleteItem( p_playlist, p_item, true );
} }
/*************************************************************************** /***************************************************************************
...@@ -880,7 +865,7 @@ static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item ) ...@@ -880,7 +865,7 @@ static void ChangeToNode( playlist_t *p_playlist, playlist_item_t *p_item )
} }
/* Do the actual removal */ /* Do the actual removal */
static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item, int playlist_DeleteItem( playlist_t * p_playlist, playlist_item_t *p_item,
bool b_stop ) bool b_stop )
{ {
int i; int i;
...@@ -891,6 +876,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item, ...@@ -891,6 +876,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
{ {
return playlist_NodeDelete( p_playlist, p_item, true, false ); return playlist_NodeDelete( p_playlist, p_item, true, false );
} }
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
var_SetInteger( p_playlist, "playlist-item-deleted", i_id ); var_SetInteger( p_playlist, "playlist-item-deleted", i_id );
......
...@@ -145,6 +145,7 @@ int playlist_ItemRelease( playlist_item_t * ); ...@@ -145,6 +145,7 @@ int playlist_ItemRelease( playlist_item_t * );
void playlist_NodesPairCreate( playlist_t *, const char *, playlist_item_t **, playlist_item_t **, bool ); void playlist_NodesPairCreate( playlist_t *, const char *, playlist_item_t **, playlist_item_t **, bool );
int playlist_NodeEmpty( playlist_t *, playlist_item_t *, bool ); int playlist_NodeEmpty( playlist_t *, playlist_item_t *, bool );
int playlist_DeleteItem( playlist_t * p_playlist, playlist_item_t *, bool);
/** /**
......
...@@ -153,8 +153,7 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root, ...@@ -153,8 +153,7 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
} }
else if( b_delete_items ) else if( b_delete_items )
{ {
playlist_DeleteFromItemId( p_playlist, playlist_DeleteItem( p_playlist, p_root->pp_children[i], true );
p_root->pp_children[i]->i_id );
} }
} }
/* Delete the node */ /* Delete the node */
......
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