[vlc-devel] commit: SD: remove category node when it becomes empty (Jakob Leben )
git version control
git at videolan.org
Mon Feb 15 19:11:50 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Mon Feb 15 19:09:33 2010 +0100| [54e0d270e2e8a8b81e83c3540f3e5bd6c9444d2e] | committer: Jakob Leben
SD: remove category node when it becomes empty
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=54e0d270e2e8a8b81e83c3540f3e5bd6c9444d2e
---
src/playlist/services_discovery.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 88c0361..fe6bfde 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -282,8 +282,25 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat
static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_data )
{
input_item_t * p_input = p_event->u.services_discovery_item_removed.p_item;
- playlist_item_t * p_parent = user_data;
- playlist_DeleteFromInput( p_parent->p_playlist, p_input, false );
+ playlist_item_t * p_sd_node = user_data;
+ playlist_t *p_playlist = p_sd_node->p_playlist;
+
+ PL_LOCK;
+ playlist_item_t *p_item =
+ playlist_ItemFindFromInputAndRoot( p_playlist, p_input,
+ p_sd_node, false );
+ if( !p_item )
+ {
+ PL_UNLOCK; return;
+ }
+ playlist_item_t *p_parent = p_item->p_parent;
+ /* if the item was added under a category and the category node
+ becomes empty, delete that node as well */
+ if( p_parent->i_children > 1 || p_parent == p_sd_node )
+ playlist_DeleteItem( p_playlist, p_item, true );
+ else
+ playlist_NodeDelete( p_playlist, p_parent, true, true );
+ PL_UNLOCK;
}
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
More information about the vlc-devel
mailing list