From: Takashi Iwai Subject: Re: [PATCH - ALSA JACK plugin 1/1] jack: Only allow ALSA periods multiple of JACKd period Date: Thu, 19 Jul 2018 20:42:12 +0200 Message-ID: References: <1531986609-10437-1-git-send-email-twischer@de.adit-jv.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 3400A26733D for ; Thu, 19 Jul 2018 20:42:12 +0200 (CEST) In-Reply-To: <1531986609-10437-1-git-send-email-twischer@de.adit-jv.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: twischer@de.adit-jv.com Cc: Laxmi Devi , alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Thu, 19 Jul 2018 09:50:09 +0200, wrote: > > From: Laxmi Devi > > 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 > Signed-off-by: Timo Wischer Applied now. Thanks. Takashi