[Live-devel] multiple selects
Alex Solbi
alexone1980 at yahoo.it
Mon Jun 8 01:32:31 PDT 2009
Hi.
My program has a main loop in which other libraries call their own select().
In order to make this call non-blocking, for each of these selects I use a timeout of 0 seconds, and I make a very short pause (about 3 milliseconds) beetween each loop cycle so to avoid a CPU heavy load.
In addition, I have subclassed TaskScheduler so to have the live555's looper inside the main loop; the result is something like this:
for(;;)
{
library1SingleStep();
library2SingleStep();
live555SingleStep();
pause(3 millisecs);
}
Now, in order to make the live555SingleStep() return immediately (so to avoid blocking the program when events don't occour), I have added a dummyTask which wakes up the MyTaskScheduler every 0 seconds.
Then I have created MyFramedSource which basically performs the following actions:
void MyFramedSource::doGetNextFrame()
{
.
.
if(frameAvailable)
deliverFrame();
else
envir().taskScheduler().scheduleDelayedTask(0, MyFramedSource::afterGettingFrame, this);
}
void MPEG4FrameSource::afterGettingFrame()
{
doGetNextFrame();
}
Now: if the MyTaskScheduler manages only one instance of MyFramedSource all seems ok (and the stream flows well) . But when there are other instances, the streams are very discontinous.
Therefore I ask:
1) can the above solution (SingleStep() + periodic dummyTask of 0 seconds + pause() between each cycle ) work if well managed? (I just need: yes/no)
2) could the line envir().taskScheduler().scheduleDelayedTask(0, MyFramedSource::afterGettingFrame, this) cause that the scheduler is called too many times (therefore the reason of my problem)?
3) How can I manage the case in which I have multiple selects? I want to avoid threads, if possible....
thanks in advance for your reply
More information about the live-devel
mailing list