Clemens Ladisch wrote:
To decrease that output buffering latency, make sure
that there is less
valid data in the buffer when you are writing. This is initially
determined by the amount of data you put into the buffer before starting
streaming, and can be later adjusted with snd_pcm_forward/rewind().
How it should work on ALSA as well as OSS for low latency:
1) Set period size to something suitable
2) Set number of periods to 2
3) Write two periods of silence to output
3.5) Optionally trigger-start both input and output
4) Block on input until period available
5) Process the input
6) Write period to the output
By this time, first of originally written periods has been played and
second is playing, now the second half of the "double buffer" gets
filled. Input buffer doesn't ever have more than one period.