[Live-devel] Proper function calls from other threads (was: RE: All client termination)
Erlandsson, Claes P (CERLANDS)
CERLANDS at arinc.com
Tue Sep 11 09:16:23 PDT 2012
Right now Live555 loop run in separate thread. The clean up function can be
called from the another thread
No! You cannot safely do this! Read the FAQ (that you were asked to do
before posting to this mailing list)!
Apart from "triggerEvent()" (see below), all calls to LIVE555 code *must* be
done within the LIVE555 thread - e.g., from a LIVE555 event handler.
For an illustration of how to shutdown (and reclaim) a "RTSPClient" object -
and all of the objects that it uses - see the function "shutdownStream()" in
"testProgs/testRTSPClient.cpp".
Now, you may wish to signal this shutdown/reclaim mechanism from an external
thread - i.e., from a thread other than one that's running the LIVE555 event
loop, for example, a GUI. To do this, use the "event trigger" mechanism
(see the FAQ and "UsageEnvironment/include/UsageEnvironment.hh"). Note that
the "triggerEvent()" function is the *only* LIVE555 function that can be
called from an external thread.
This is a mistake I first made, even after reading the FAQ. I somehow didn't
think about that I was calling shutdown and issue PLAY-commands (seek) from
my own thread (since it usually works fine). Looking at the example code I
however thought it was safe to schedule tasks. After reading your response
above I'd like to verify that what I do is correct.
My question is... I'm not calling triggerEvent() directly, but instead
scheduling tasks using the taskScheduler. The code example below is called
from an external thread. Is that ok, and the proper way to do it?
void StopStream(OurRTSPClient *rtspClient)
{
if (rtspClient)
{
UsageEnvironment& env = rtspClient->envir();
env.taskScheduler().scheduleDelayedTask(TASK_FUNCTION_CALL_DELAY_MS,
(TaskFunc*)StopStreamTask, rtspClient);
}
}
/Claes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120911/30317e64/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5740 bytes
Desc: not available
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120911/30317e64/attachment-0001.bin>
More information about the live-devel
mailing list