Lifetime of libvlc_new args

This forum is about all development around libVLC.
User101
New Cone
New Cone
Posts: 8
Joined: 21 Aug 2016 22:07

Lifetime of libvlc_new args

Postby User101 » 23 Oct 2018 16:07

Hello,
I'm currently implementing the argument option for libvlc_new in rust.
Because of rust internal Strings to c_string conversion I have to ask: does the argument have to be alive longer than the call of libvlc_new ?

Example in pseudo code

Code: Select all

var a = ["--no-video"]; var instance = libvlc_new(1,a); free(a); .. use instance
I've tried digging through the source but the amount of places where arg is used and the missing doc about the lifetime of the argument makes it pretty hard to understand whether or not I need to keep this variable allocated.

User101
New Cone
New Cone
Posts: 8
Joined: 21 Aug 2016 22:07

Re: Lifetime of libvlc_new args

Postby User101 » 23 Oct 2018 16:08

(Also I'm welcoming hints for how to disable video playback programmatically, instead of arguments.)

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Lifetime of libvlc_new args

Postby mfkl » 24 Oct 2018 04:51

https://github.com/videolan/vlc-3.0/blo ... .c#L51-L52
I'd say you should be fine freeing them after the call has returned. Try it anyway.
(Also I'm welcoming hints for how to disable video playback programmatically, instead of arguments.)
You need to use

Code: Select all

libvlc_media_tracks_get libvlc_video_set_track
https://mfkl.github.io

User101
New Cone
New Cone
Posts: 8
Joined: 21 Aug 2016 22:07

Re: Lifetime of libvlc_new args

Postby User101 » 24 Oct 2018 12:30

Thanks for the answer.
Yeah, in retrospect it makes sense that this is a full copy of argv..
Edit: I've tried it and it also doesn't crash, did some verification with valgrind.

About get_track & set I'll have to see. My understanding was that you can't do this until media has started when it's a stream. But I'll try again today, this at least steers me on the right track ;) .

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Lifetime of libvlc_new args

Postby Rémi Denis-Courmont » 24 Oct 2018 21:32

Please refer to Doxygen. The only supported way to use libvlc_new() is to pass zero arguments, and then your question is moot.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: m1adow and 21 guests