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

From: Tim Goetze <tim@email-addr-hidden>
Date: Tue Dec 20 2011 - 15:24:35 EET

[Paul Davis]

>On Mon, Dec 19, 2011 at 8:10 PM, Iain Duncan <iainduncanlists@email-addr-hidden> 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.

Alternatively, out-of-order queuing can be dealt with by sorting the
contents of the FIFO in the consuming thread (since the write position
only ever increases, sorting everything before it is safe). Multiple
writers can be supported locklessly by employing one FIFO per writing
thread (the consuming thread peeks at the contents of all FIFOs before
deciding which event to pop first).

Tim
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Tue Dec 20 16:15:02 2011

This archive was generated by hypermail 2.1.8 : Tue Dec 20 2011 - 16:15:02 EET