[Live-devel] New TaskScheduler 'event trigger' mechanism, and (much) improved "DeviceSource"

P.J. pj81102 at gmail.com
Mon Dec 13 19:21:13 PST 2010


Hi,Ross,
     I'm doubting this piece of code works correctly.
void BasicTaskScheduler0::triggerEvent(EventTriggerId eventTriggerId, 
void* clientData) {
   // First, record the "clientData":
   if (eventTriggerId == fLastUsedTriggerMask) { // common-case 
optimization:
     fTriggeredEventClientDatas[*eventTriggerId*] = clientData; // here 
not use *fLastUsedTriggerNum*???
   }
...
}

? 2010-12-11 14:19, Ross Finlayson ??:
> One of the biggest problems that developers have had with this library 
> is that it has been difficult to define and handle new kinds of event 
> - beyond the file/socket I/O and delayed task events that we support 
> by default.
>
> In particular, it has been difficult to implement input devices (such 
> as encoders) when we want to signal a new event (such as the 
> availability of new frame data) from an external thread.  The 'watch 
> variable' mechanism - although it can be used - is not particular 
> well-suited for this purpose.  Furthermore, the model code in 
> "DeviceSource.cpp" has not been particular helpful, because it doesn't 
> really describe what to do to handle events that are signaled from an 
> external thread.
>
> To overcome this, I have now installed a new version (2010.12.11) of 
> the "LIVE555 Streaming Media" library that now includes a new 'event 
> trigger' mechanism for "TaskScheduler" (and its subclass, 
> "BasicTaskScheduler").
>
> Specifically, you can now - using the new function
>     TaskScheduler::createEventTrigger()
> - register an event handler function, to be associated with a 
> particular 'event trigger id'.  At some later time, you can call
>     TaskScheduler:: triggerEvent()
> with this 'event trigger id' as parameter, and this will cause the 
> event handler function to get called (from within the event loop).
>
> For more details, see "UsageEnvironment/include/UsageEnvironment.hh"
>
> One nice feature of this mechanism is that - unlike other library 
> routines - the "triggerEvent()" function can be called from a separate 
> thread.  This makes it easier to implement input device classes.
>
>
> I have also updated (and, I hope, significantly improved) the model 
> code in "liveMedia/DeviceSource.cpp".  This code describes how to 
> implement an input device class that uses the new 'event trigger' 
> mechanism (with the event possibly being signaled from an external 
> thread).
>
> If you're implementing (or have already implemented) an input device 
> class, then I encourage you to take a look at the new "DeviceSource" 
> code - and perhaps use this as a model for your code.


-- 
*P.J.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20101214/17d35e80/attachment.html>


More information about the live-devel mailing list