diff --git a/include/vlc_media_source.h b/include/vlc_media_source.h index 02c94eb5d58ad40ad8b73d93f36ffe43dc646558..36e1f9a0b869ecb996a719cbfdc895936cc83587 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 90161d6fcdaf64003559a212039cae872a8e7afe..ed2df3be42b1706fd9601ff3aa0f5355c0b6ed00 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