[vlc-devel] commit: playlist: make playlist_DeleteFromInput delete container nodes as well (Jakob Leben )
git version control
git at videolan.org
Sun Jan 31 17:29:03 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sun Jan 31 14:02:01 2010 +0100| [2dfe5574f7b5a39a3ec2af1e27c72e3d2fe8e8c5] | committer: Jakob Leben
playlist: make playlist_DeleteFromInput delete container nodes as well
and refactor playlist code for optimization
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2dfe5574f7b5a39a3ec2af1e27c72e3d2fe8e8c5
---
src/playlist/item.c | 28 +++++++---------------------
src/playlist/playlist_internal.h | 1 +
src/playlist/tree.c | 3 +--
3 files changed, 9 insertions(+), 23 deletions(-)
diff --git a/src/playlist/item.c b/src/playlist/item.c
index 0dc9f10..f6a7528 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -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,
playlist_item_t *, playlist_item_t * );
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 );
@@ -239,24 +237,11 @@ int playlist_ItemRelease( playlist_item_t *p_item )
static int DeleteFromInput( playlist_t *p_playlist, input_item_t *p_input,
playlist_item_t *p_root, bool b_do_stop )
{
- int i;
PL_ASSERT_LOCKED;
- for( i = 0 ; i< p_root->i_children ; i++ )
- {
- if( p_root->pp_children[i]->i_children == -1 &&
- p_root->pp_children[i]->p_input == p_input )
- {
- 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;
+ playlist_item_t *p_item = playlist_ItemFindFromInputAndRoot(
+ p_playlist, p_input, p_root, false );
+ if( !p_item ) return VLC_EGENERIC;
+ return playlist_DeleteItem( p_playlist, p_item, b_do_stop );
}
/**
@@ -332,7 +317,7 @@ int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
PL_ASSERT_LOCKED;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
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 )
}
/* 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 )
{
int i;
@@ -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 );
}
+
pl_priv(p_playlist)->b_reset_currently_playing = true;
var_SetInteger( p_playlist, "playlist-item-deleted", i_id );
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 6a46b49..efe3c5b 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -145,6 +145,7 @@ int playlist_ItemRelease( playlist_item_t * );
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_DeleteItem( playlist_t * p_playlist, playlist_item_t *, bool);
/**
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index 2ab2bac..54fb47e 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -153,8 +153,7 @@ int playlist_NodeDelete( playlist_t *p_playlist, playlist_item_t *p_root,
}
else if( b_delete_items )
{
- playlist_DeleteFromItemId( p_playlist,
- p_root->pp_children[i]->i_id );
+ playlist_DeleteItem( p_playlist, p_root->pp_children[i], true );
}
}
/* Delete the node */
More information about the vlc-devel
mailing list