[vlc-commits] media_tree: allow preparse tasks to be canceled
Pierre Lamot
git at videolan.org
Thu Feb 13 11:06:32 CET 2020
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Wed Feb 5 17:49:28 2020 +0100| [dffaaca48e935e64de87714279aa07d7da658fc9] | committer: Jean-Baptiste Kempf
media_tree: allow preparse tasks to be canceled
If we need to release the media tree before the preparse ends
the preparse callback will likely crash.
This allows to pass an optional task id to vlc_media_tree_Preparse and to
cancel it afterwards
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dffaaca48e935e64de87714279aa07d7da658fc9
---
include/vlc_media_source.h | 13 ++++++++++++-
modules/gui/macosx/media-source/VLCMediaSource.m | 2 +-
modules/gui/qt/network/networkmediamodel.cpp | 3 +--
src/libvlccore.sym | 1 +
src/media_source/media_tree.c | 17 +++++++++++++++--
5 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/include/vlc_media_source.h b/include/vlc_media_source.h
index 36e1f9a0b8..9a26ddb39a 100644
--- a/include/vlc_media_source.h
+++ b/include/vlc_media_source.h
@@ -191,10 +191,21 @@ vlc_media_tree_Find(vlc_media_tree_t *tree, const input_item_t *media,
* \param tree the media tree (not necessarily locked)
* \param libvlc the libvlc instance
* \param media the media to preparse
+ * \param id a task identifier
*/
VLC_API void
vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
- input_item_t *media);
+ input_item_t *media, void *id);
+
+
+/**
+ * Cancel a media tree preparse request
+ *
+ * \param libvlc the libvlc instance
+ * \param id the preparse task id
+ */
+VLC_API void
+vlc_media_tree_PreparseCancel(libvlc_int_t *libvlc, void* id);
/**
* Media source.
diff --git a/modules/gui/macosx/media-source/VLCMediaSource.m b/modules/gui/macosx/media-source/VLCMediaSource.m
index eb187fd1ea..4c01af0749 100644
--- a/modules/gui/macosx/media-source/VLCMediaSource.m
+++ b/modules/gui/macosx/media-source/VLCMediaSource.m
@@ -128,7 +128,7 @@ static const struct vlc_media_tree_callbacks treeCallbacks = {
if (inputItem == nil) {
return;
}
- vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, inputItem.vlcInputItem);
+ vlc_media_tree_Preparse(_p_mediaSource->tree, _p_libvlcInstance, inputItem.vlcInputItem, NULL);
}
- (NSString *)mediaSourceDescription
diff --git a/modules/gui/qt/network/networkmediamodel.cpp b/modules/gui/qt/network/networkmediamodel.cpp
index c2561e1620..1a24f3de91 100644
--- a/modules/gui/qt/network/networkmediamodel.cpp
+++ b/modules/gui/qt/network/networkmediamodel.cpp
@@ -255,8 +255,7 @@ bool NetworkMediaModel::initializeMediaSources()
emit isIndexedChanged();
}
-
- vlc_media_tree_Preparse( tree, libvlc, m_treeItem.media.get() );
+ vlc_media_tree_Preparse( tree, libvlc, m_treeItem.media.get(), this );
m_parsingPending = true;
emit parsingPendingChanged(m_parsingPending);
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index cf0f2230a1..befaab5151 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -947,6 +947,7 @@ vlc_media_tree_Lock
vlc_media_tree_Unlock
vlc_media_tree_Find
vlc_media_tree_Preparse
+vlc_media_tree_PreparseCancel
vlc_viewpoint_to_4x4
vlc_video_context_Create
vlc_video_context_Release
diff --git a/src/media_source/media_tree.c b/src/media_source/media_tree.c
index ed2df3be42..017325719f 100644
--- a/src/media_source/media_tree.c
+++ b/src/media_source/media_tree.c
@@ -342,17 +342,30 @@ static const input_preparser_callbacks_t input_preparser_callbacks = {
void
vlc_media_tree_Preparse(vlc_media_tree_t *tree, libvlc_int_t *libvlc,
- input_item_t *media)
+ input_item_t *media, void* id)
{
#ifdef TEST_MEDIA_SOURCE
VLC_UNUSED(tree);
VLC_UNUSED(libvlc);
VLC_UNUSED(media);
+ VLC_UNUSED(id);
VLC_UNUSED(input_preparser_callbacks);
#else
media->i_preparse_depth = 1;
vlc_MetadataRequest(libvlc, media, META_REQUEST_OPTION_SCOPE_ANY |
META_REQUEST_OPTION_DO_INTERACT,
- &input_preparser_callbacks, tree, 0, NULL);
+ &input_preparser_callbacks, tree, 0, id);
+#endif
+}
+
+
+void
+vlc_media_tree_PreparseCancel(libvlc_int_t *libvlc, void* id)
+{
+#ifdef TEST_MEDIA_SOURCE
+ VLC_UNUSED(libvlc);
+ VLC_UNUSED(id);
+#else
+ libvlc_MetadataCancel(libvlc, id);
#endif
}
More information about the vlc-commits
mailing list