[vlc-commits] sd: use playlist_ItemGetByInput()
Rémi Denis-Courmont
git at videolan.org
Sun May 14 18:37:16 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May 14 16:07:08 2017 +0300| [19576662c8cd01be621a0d4473af575009598831] | committer: Rémi Denis-Courmont
sd: use playlist_ItemGetByInput()
playlist_ItemFindFromInputAndRoot() asymptotically is much slower than
playlist_ItemGetByInput(), so use the latter.
However, this means that an input item from another SD or from the playlist
can also be returned. So add an assertion against it.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19576662c8cd01be621a0d4473af575009598831
---
src/playlist/services_discovery.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 6796a8fc39..b64893a7c9 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -77,22 +77,31 @@ static void playlist_sd_item_removed(services_discovery_t *sd,
{
vlc_sd_internal_t *sds = sd->owner.sys;
playlist_t *p_playlist = (playlist_t *)sd->obj.parent;
- playlist_item_t *p_sd_node = sds->node;
+ playlist_item_t *node, *item;
PL_LOCK;
- playlist_item_t *p_item =
- playlist_ItemFindFromInputAndRoot( p_playlist, p_input, p_sd_node );
- if( !p_item )
+ item = playlist_ItemGetByInput(p_playlist, p_input);
+ if (unlikely(item == NULL))
{
- PL_UNLOCK; return;
+ msg_Err(sd, "removing item not added"); /* SD plugin bug */
+ PL_UNLOCK;
+ return;
}
- playlist_item_t *p_parent = p_item->p_parent;
+
+#ifndef NDEBUG
+ /* Check that the item belonged to the SD */
+ for (playlist_item_t *i = item->p_parent; i != sds->node; i = i->p_parent)
+ assert(i != NULL);
+#endif
+
+ node = 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_NodeDelete( p_playlist, p_item, false );
+ if (node != sds->node && node->i_children == 1)
+ playlist_NodeDelete(p_playlist, node, true);
else
- playlist_NodeDelete( p_playlist, p_parent, true );
+ playlist_NodeDelete(p_playlist, item, true);
+
PL_UNLOCK;
}
More information about the vlc-commits
mailing list