On Thu, 19 Jul 2018 09:50:09 +0200, twischer@de.adit-jv.com wrote:
From: Laxmi Devi ldevi@de.adit-jv.com
There is a higher Xrun probability whenever the ALSA period is not a multiple of the JACKd period and the ALSA buffer is only twice the period. Allowing ALSA buffers of min. 3x period is not a good solution because this would increase the latency.
As an example in case of ALSA is using a period of 11 frames and JACK a period of 12 frames and a buffer of 22 frames (2x ALSA period) is used:
- The buffer is filled and contains 22 frames
- JACK is reading 12 frames. Buffer is only containing 10 frames
- Now, ALSA has to be scheduled exactly after the last JACK read and before the next read. Otherwise we will get an Xrun
In case of ALSA is using a multiple period of JACK, JACK can always read 2 periods before an Xrun if the buffer was full.
In case of ALSA is using a period of 12 frames and JACK a period of 11 frames and a buffer of 24 frames (2x ALSA period) is used:
- The buffer is filled and contains 24 frames
- JACK is reading 11 frames. Buffer is now containing 13 frames. But ALSA can still not write to the buffer
- JACK reads 11 additional frames. Buffer contains 2 frames
- Now, ALSA has to be scheduled exactly after the last JACK read and before the next read. Otherwise we will get an Xrun
In case of ALSA is using a multiple period of JACK, ALSA can always write to the buffer as long as the buffer is filled with less or equal of half of buffer.
Therefore this patch enforces an ALSA period which is always a multiple of the JACKd period.
Signed-off-by: Laxmi Devi ldevi@de.adit-jv.com Signed-off-by: Timo Wischer twischer@de.adit-jv.com
Applied now. Thanks.
Takashi