[LAD] how to store deferred events in a real time audio app?

Paul Davis paul at linuxaudiosystems.com
Tue Dec 20 03:49:22 UTC 2011


On Mon, Dec 19, 2011 at 8:10 PM, Iain Duncan <iainduncanlists at gmail.com> wrote:

> However, I would like to add the ability for the user to send a message and
> have it get executed later, where later gets figured out by the engine ( ie
> on the top of the next 8 bar phrase ). To do this, I need some way of
> storing deferred events and having the engine check on each step whether
> there were any deferred events stored for 'now'. I can think of a few ways
> to do this, and all of them raise red flags for a real time thread.

1) don't allow out-of-order queuing
2) just use a FIFO (i.e. ye olde single-reader/single-writer lock free
ringbuffer) to enqueue events between the engine and another thread
(presumably a GUI)

things get more complex if you insist on allowing out-of-order queuing
and/or more than one thread is delivering events. but not a lot more.
you can so multi-writer/single-reader FIFO in an RT safe way by
requiring a lock to write, but none to read, which serializes writes
and reduces it to an effectively single-writer/single reader
situation.



More information about the Linux-audio-dev mailing list