When is it safe to call libvlc_media_release?

This forum is about all development around libVLC.
geoffs
New Cone
New Cone
Posts: 3
Joined: 18 Apr 2011 22:28

When is it safe to call libvlc_media_release?

Postby geoffs » 18 Apr 2011 22:46

I think I'm missing something about the thread safety of libvlc functions.

When is it safe to call libvlc_media_release? Specifically, if I call libvlc_media_player_get_media, then at some point I will need to release the returned media, but there is no locking in libvlc_media_release to protect the media's ref count. I see that media_player's function are careful to lock the media_player's object mutex before retaining or releasing the media, but I see no way to lock on that mutex from outside the player. Do I need to not release the media until after the player's media has been changed with libvlc_media_player_set_media? That seems like a big burden... I hope I'm just misunderstanding something.

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

Re: When is it safe to call libvlc_media_release?

Postby Rémi Denis-Courmont » 19 Apr 2011 11:13

I wouldn't overestimate the quality and thinking behind that piece of code.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

rwalden
New Cone
New Cone
Posts: 4
Joined: 26 Jun 2013 00:28

Re: When is it safe to call libvlc_media_release?

Postby rwalden » 26 Jun 2013 00:37

I know this is an old post, but I too would like to know the answer to this question, quality of the thinking that went into the code aside.
Does the player increment the reference count of the media when you call libvlc_media_player_set_media()?

I have seen example code that calls libvlc_media_release() immediately after libvlc_media_player_set_media().

So is this the way to do it or not?

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

Re: When is it safe to call libvlc_media_release?

Postby Rémi Denis-Courmont » 26 Jun 2013 21:09

I'd say check the source code. If that's the way it is, submit a patch against the Doxygen documentation to make it clear. And if not, you have your answer.
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: No registered users and 15 guests