[vlc-devel] [PATCH] Handle GET_PARAMETER keepalive responses during PAUSE

Ross Finlayson finlayson at live555.com
Wed Jun 24 21:57:43 CEST 2015


>> Ensuring provable thread-safety 
>> of this stuff is beyond my understanding of VLC internals I'm afraid.
> 
> I believe the patch makes crashes much more likely though. That being said, I 
> do not maintain this particular VLC plugin. Its maintainer(s) should decide on 
> what to do.

I’m not responsible for, or familiar with, VLC’s LIVE555 interface code (“live555.cpp”) either.  I just wanted to make clear, however, that the way that application code that calls LIVE555 is *supposed* to be written is that only one thread (the ‘LIVE555 event loop thread’) is ever supposed to call functions in the LIVE555 library (including “sendPauseCommand()”, “sendGetParameterCommand()”, and “sendPlayCommand()”).  The reason for this is LIVE555-based applications run in a single thread of control, using an event loop - rather than multiple threads - for concurrency.  (For a longer discussion of this, see the LIVE555 FAQ.)

So, I hope that this is true in whatever changes you are proposing for “live555.cpp”: Only the ‘LIVE555 event loop’ thread is supposed to be calling LIVE555 library functions.  Where this gets complicated is in applications - like VLC - that have their own, separate ‘event’ mechanism as well.

The way that people usually handle this (no pun intended) is to continue to have one thread running the LIVE555 event loop, but use other thread(s) to ‘signal' to the LIVE555 event loop that there are LIVE555 events that it needs to handle.  There are two common ways in which this is done:
	1/ Use a ‘watch variable’ as a parameter to the LIVE555 “doEventLoop()” call.  If this ‘watch variable’ is ever set (externally) to a non-zero value, then the LIVE555 thread will return from the call to “doEventLoop()” (and presumably call “doEventLoop()” again later).  (I see that you do this already in “live555.cpp”.  I notice, however, that you call “doEventLoop()” in two places, with two different ‘watch variables’.  Be sure that the external VLC thread(s) (that set the ‘watch variable’) knows which 'watch variable’ is being used at an given time.)
	2/ Use LIVE555’s ‘event trigger’ mechanism, which is a more sophisticating way of signaling the LIVE555 event loop from an external thread.  With this mechanism, an ‘event trigger’ object (and handler) is created within the LIVE555 event loop, and then - to signal the event - an external thread calls “triggerEvent()”.  (This is the only LIVE555 function that may be called from an external thread.)

I hope this helps.

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150624/a59cadba/attachment.html>


More information about the vlc-devel mailing list