[vlc-commits] lib: media: fix libvlc_media_duplicate() behavior
Thomas Guillem
git at videolan.org
Mon Oct 5 09:19:55 CEST 2020
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct 2 16:14:57 2020 +0200| [101407d735e8bda8f89e53bd52c108e41ddfdebe] | committer: Thomas Guillem
lib: media: fix libvlc_media_duplicate() behavior
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=101407d735e8bda8f89e53bd52c108e41ddfdebe
---
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 cd203e8eda..904e265561 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 c88b7df56e..2175c04b98 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
More information about the vlc-commits
mailing list