[vlc-devel] [PATCHv3 6/7] lib: media: copy the input item

Thomas Guillem thomas at gllm.fr
Tue Sep 22 14:09:57 CEST 2020


In order to avoid having more than one libvlc_media_t using the same
input_item_t.

And to assert that one input_item has only one unique owner. Cf. next
commit.
---
 lib/media.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/media.c b/lib/media.c
index 0c1a58be8cd..da0e5777b5c 100644
--- a/lib/media.c
+++ b/lib/media.c
@@ -511,7 +511,10 @@ libvlc_media_t * libvlc_media_new_from_input_item(
     if( p_md == NULL )
         return NULL;
 
-    return libvlc_media_attach_input_item( p_md, p_input_item );
+    input_item_t *p_item_copy = input_item_Copy( p_input_item, NULL );
+    if( p_item_copy != NULL )
+        return libvlc_media_attach_input_item( p_md, p_item_copy );
+    return NULL;
 }
 
 // Create a media with a certain given media resource location
-- 
2.28.0



More information about the vlc-devel mailing list