From nobody Fri Dec 19 07:47:26 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54EAAC6FA82 for ; Tue, 13 Sep 2022 14:11:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232860AbiIMOLr (ORCPT ); Tue, 13 Sep 2022 10:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232755AbiIMOKR (ORCPT ); Tue, 13 Sep 2022 10:10:17 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E54B2ACF; Tue, 13 Sep 2022 07:09:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 0BF06CE1273; Tue, 13 Sep 2022 14:09:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85CCFC433C1; Tue, 13 Sep 2022 14:09:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663078169; bh=t1P3kWJlr3FRz90YArACEMVnqBprOqufRoCxhUOe9P0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKKkZBBIO2N+G6uPa760TJXR3CNuN6e4mcUXbTEhvOYib2IkswUMPgpv9NwVliEPI Y5JBxZOmZwOSc6MLI2lwLDsInC2rH+mOwioYk7ryX9JPPvviZSbHFCOT8FllEIekcS dQGyfmnM7gmm44uGqVqYzozZj363GZ5arbWavXz4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pattara Teerapong , Takashi Iwai Subject: [PATCH 5.19 038/192] ALSA: aloop: Fix random zeros in capture data when using jiffies timer Date: Tue, 13 Sep 2022 16:02:24 +0200 Message-Id: <20220913140411.816990294@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140410.043243217@linuxfoundation.org> References: <20220913140410.043243217@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pattara Teerapong commit 3e48940abee88b8dbbeeaf8a07e7b2b6be1271b3 upstream. In loopback_jiffies_timer_pos_update(), we are getting jiffies twice. First time for playback, second time for capture. Jiffies can be updated between these two calls and if the capture jiffies is larger, extra zeros will be filled in the capture buffer. Change to get jiffies once and use it for both playback and capture. Signed-off-by: Pattara Teerapong Cc: Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromiu= m.org Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/drivers/aloop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/sound/drivers/aloop.c +++ b/sound/drivers/aloop.c @@ -605,17 +605,18 @@ static unsigned int loopback_jiffies_tim cable->streams[SNDRV_PCM_STREAM_PLAYBACK]; struct loopback_pcm *dpcm_capt =3D cable->streams[SNDRV_PCM_STREAM_CAPTURE]; - unsigned long delta_play =3D 0, delta_capt =3D 0; + unsigned long delta_play =3D 0, delta_capt =3D 0, cur_jiffies; unsigned int running, count1, count2; =20 + cur_jiffies =3D jiffies; running =3D cable->running ^ cable->pause; if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) { - delta_play =3D jiffies - dpcm_play->last_jiffies; + delta_play =3D cur_jiffies - dpcm_play->last_jiffies; dpcm_play->last_jiffies +=3D delta_play; } =20 if (running & (1 << SNDRV_PCM_STREAM_CAPTURE)) { - delta_capt =3D jiffies - dpcm_capt->last_jiffies; + delta_capt =3D cur_jiffies - dpcm_capt->last_jiffies; dpcm_capt->last_jiffies +=3D delta_capt; }