~vcs-imports/alsa-plugins/trunk

Viewing all changes in revision 304.

  • Committer: Takashi Iwai
  • Author(s): Laxmi Devi
  • Date: 2018-07-19 18:41:31 UTC
  • Revision ID: git-v1:72337f1dcb2df6a2b7fdae93e88d7dd3a7e97ab4
jack: Only allow ALSA periods multiple of JACKd period

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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: