How to detect and handle output errors

This forum is about all development around libVLC.
hvz
New Cone
New Cone
Posts: 6
Joined: 30 May 2014 10:31

How to detect and handle output errors

Postby hvz » 01 Jun 2014 22:04

I'm adding VLC output audio streaming (to a Shoutcast server for example) to my software. I'm already using VLC to receive input streams and that works fine. Output streaming works fine as well, except when something goes wrong.

I've subscribed to libvlc_MediaPlayerEncounteredError events using libvlc_event_attach. But if something goes wrong (for example a shoutcast server is not available), the callback in my software never gets called. What's worse: I'm using IMEM to send audio to VLC, and if I call libvlc_media_player_stop the program blocks until I return some data in the callback that was set with --imem-get=<address>. But when there is an output error, this callback is never called (I could use that to detect an error situation) and the stop function locks as well.

To be clear: If there's no error situation, the stop function does not lock, also I'm not calling it from the same thread that contains the message pump (which also still works during a lockup). If I only call release, it works - but I'm afraid of memory or other leaks...

So, I'd like to know how to properly detect and handle this type of errors.

Code: Select all

vlcInstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); assert(vlcInstance != NULL); libvlc_media_t *m = libvlc_media_new_location (vlcInstance, "imem://"); assert(m != NULL); mp = libvlc_media_player_new_from_media (m); libvlc_media_release (m); m = NULL; assert(mp != NULL) libvlc_event_manager_t* em = libvlc_media_player_event_manager(mp); int r = libvlc_event_attach(em, libvlc_MediaPlayerEncounteredError, &VLCErrorCallback, this); assert(r==0); int r2 = libvlc_media_player_play (mp); assert(r2==0);

Code: Select all

libvlc_media_player_stop (mp); // HANGS in case of error libvlc_media_player_release (mp); mp = NULL; // HANGS in case of error (if I skip stop) libvlc_release (vlcInstance); vlcInstance = NULL;

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: How to detect and handle output errors

Postby Jean-Baptiste Kempf » 05 Jun 2014 14:51

This is a design limitation of imem. indeed. I'm afraid you'll have to fix the imem code in VLC.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 6 guests