[alsa-devel] Alsa timing question

Olivier Guillion - Myriad olivier at myriad-online.com
Sat Aug 27 10:08:32 CEST 2011


Hi,

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 :)

>  Plus, I think that when I
> request new data, something is always written.

I thought it was asynchronous, and you just send a signal to your generating 
process to ask it generate data.

> Clemens idea of a counter at the beginning of the buffer would work nicely, but
> requires changes in the generating process.

Right. But if you can modify  the generating process and recompile it, there is 
no more problem. Can you?

Olivier



More information about the Alsa-devel mailing list