[vlc-commits] media_tree: send notification when preparse is complete
Pierre Lamot
git at videolan.org
Thu Oct 31 01:02:19 CET 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Mon Oct 21 18:08:54 2019 +0200| [ac41d4620669b251d756719176aa4dca0e29b880] | committer: Jean-Baptiste Kempf
media_tree: send notification when preparse is complete
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ac41d4620669b251d756719176aa4dca0e29b880
---
include/vlc_media_source.h | 13 +++++++++++++
src/media_source/media_tree.c | 22 ++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/include/vlc_media_source.h b/include/vlc_media_source.h
index 02c94eb5d5..36e1f9a0b8 100644
--- a/include/vlc_media_source.h
+++ b/include/vlc_media_source.h
@@ -111,6 +111,19 @@ struct vlc_media_tree_callbacks
(*on_children_removed)(vlc_media_tree_t *tree, input_item_node_t *node,
input_item_node_t *const children[], size_t count,
void *userdata);
+
+ /**
+ * Called when the preparsing of a node is complete
+ *
+ * \param tree the media tree
+ * \param node the node being parsed
+ * \param status the reason for the preparsing termination
+ * \param userdata userdata provided to AddListener()
+ */
+ void
+ (*on_preparse_end)(vlc_media_tree_t *tree, input_item_node_t * node,
+ enum input_item_preparse_status status,
+ void *userdata);
};
/**
diff --git a/src/media_source/media_tree.c b/src/media_source/media_tree.c
index 90161d6fcd..ed2df3be42 100644
--- a/src/media_source/media_tree.c
+++ b/src/media_source/media_tree.c
@@ -168,6 +168,27 @@ media_subtree_changed(input_item_t *media, input_item_node_t *node,
vlc_media_tree_Unlock(tree);
}
+static void
+media_subtree_preparse_ended(input_item_t *media,
+ enum input_item_preparse_status status,
+ void *user_data)
+{
+ vlc_media_tree_t *tree = user_data;
+
+ vlc_media_tree_Lock(tree);
+ input_item_node_t *subtree_root;
+ /* TODO retrieve the node without traversing the tree */
+ bool found = vlc_media_tree_FindNodeByMedia(&tree->root, media,
+ &subtree_root, NULL);
+ if (!found) {
+ /* the node probably failed to be allocated */
+ vlc_media_tree_Unlock(tree);
+ return;
+ }
+ vlc_media_tree_Notify(tree, on_preparse_end, subtree_root, status);
+ vlc_media_tree_Unlock(tree);
+}
+
static inline void
vlc_media_tree_DestroyRootNode(vlc_media_tree_t *tree)
{
@@ -316,6 +337,7 @@ vlc_media_tree_Remove(vlc_media_tree_t *tree, input_item_t *media)
static const input_preparser_callbacks_t input_preparser_callbacks = {
.on_subtree_added = media_subtree_changed,
+ .on_preparse_ended = media_subtree_preparse_ended
};
void
More information about the vlc-commits
mailing list