[alsa-devel] Alsa timing question

Jassi Brar jassisinghbrar at gmail.com
Sat Aug 27 11:15:14 CEST 2011


On Sat, Aug 27, 2011 at 1:38 PM, Olivier Guillion - Myriad
<olivier at myriad-online.com> wrote:
> Raymond Toy <rtoy at google.com> wrote :
>> > IMO, it's not a good idea to try to synchronize perfectly two processes by way
>> > of an interrupt. If the generating process has to remain untouched, you should
>> > probably bufferize its data in your own process before sending it to writei.
>> > It would add some latency, but make the data flow safer. Here is how it could
>> > work: 1- Your process writes a "magic" pattern at the end of the shared area
>> > 2- It sends a signal to the other process to make it generate data 3- It
>> > checks whether the magic pattern is still here 4- When changed, it means the
>> > data have been calculated. It saves them to an internal circular buffer
>> >
>>
>> A nice idea, but I'm not sure it will work in my scenario.  The "magic"
>> pattern could potentially be real data (the buffer contains audio samples), so
>> that would cause funny, hard-to-reproduce glitches.
>
> You are theorically right, even if I doubt that much genuine audio buffer could
> end with, let's say : 0x8000 0x7FFF followed by "This is magic!!!" string :)
>
It can be made simpler.
If anything like that, I tend to agree with Clemens idea if he meant each
chunk (particular size of data written by the producer process and read by
consumer process) starts with a, say 32bits, serial number.
After reading, the reader resets the serial to 0, for the writer to
get the message
that the data has been consumed.


More information about the Alsa-devel mailing list