[vlc-devel] [PATCH 3/3] lib: media: fix libvlc_media_duplicate() behavior
Thomas Guillem
thomas at gllm.fr
Fri Oct 2 16:19:40 CEST 2020
The new duplicated media should not share events of the orignal one.
Ie. parsing the original media should not trigger updates on the
duplicated media.
---
include/vlc/libvlc_media.h | 3 +++
lib/media.c | 7 +++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index cd203e8edaa..904e2655612 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -450,6 +450,9 @@ LIBVLC_API char *libvlc_media_get_mrl( libvlc_media_t *p_md );
/**
* Duplicate a media descriptor object.
*
+ * \warning the duplicated media won't share forthcoming updates from the
+ * original one.
+ *
* \param p_md a media descriptor object.
*/
LIBVLC_API libvlc_media_t *libvlc_media_duplicate( libvlc_media_t *p_md );
diff --git a/lib/media.c b/lib/media.c
index c88b7df56ee..2175c04b98d 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -649,8 +649,11 @@ void libvlc_media_retain( libvlc_media_t *p_md )
libvlc_media_t *
libvlc_media_duplicate( libvlc_media_t *p_md_orig )
{
- return libvlc_media_new_from_input_item(
- p_md_orig->p_libvlc_instance, p_md_orig->p_input_item );
+
+ input_item_t *dup = input_item_Copy( p_md_orig->p_input_item );
+ if( dup == NULL )
+ return NULL;
+ return libvlc_media_new_from_input_item( p_md_orig->p_libvlc_instance, dup );
}
// Get mrl from a media descriptor object
--
2.28.0
More information about the vlc-devel
mailing list