From mboxrd@z Thu Jan 1 00:00:00 1970 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1773BC87FCC for ; Thu, 31 Jul 2025 13:01:06 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [45.14.194.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EF40160239; Thu, 31 Jul 2025 15:00:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF40160239 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1753966865; bh=d8e2uIkRjmv2L4zoy4Vznfofv9hJse41+E2Pqv33Xk4=; h=From:To:In-Reply-To:References:Subject:Date:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From; b=DMmXxhR5dELFrxQM/9oT1ZYaoGdO8uFlrCub4464sfQ6vFZsqMAueE1/W93UvpxgO 5in9bNS8OiNewwMLRVuw1Quw4qPoAKyWszIJ4cag9hECktF95aRD6W1u+RoDgNF910 7snNPyVMvjjKl4uWg+/d7IcpsT5jcKmUCQEHITJc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E16D7F805C6; Thu, 31 Jul 2025 15:00:26 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 000FCF805D4; Thu, 31 Jul 2025 15:00:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C406EF8025F; Thu, 31 Jul 2025 15:00:00 +0200 (CEST) Received: from webhooks-bot.alsa-project.org (vmi2259423.contaboserver.net [45.14.194.44]) by alsa1.perex.cz (Postfix) with ESMTP id 7A056F8016A for ; Thu, 31 Jul 2025 14:59:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7A056F8016A MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit From: GitHub pull_request - opened To: alsa-devel@alsa-project.org Message-Id: <18575781691c7c00-webhooks-bot@alsa-project.org> In-Reply-To: References: Subject: pcm: add a loop to snd_pcm_avail_delay() to avoid bogus delay values Date: Thu, 31 Jul 2025 15:00:00 +0200 (CEST) Message-ID-Hash: BLM4KSV7VZADGRXQOIJ4IC4V6IBOQFPG X-Message-ID-Hash: BLM4KSV7VZADGRXQOIJ4IC4V6IBOQFPG X-MailFrom: github@alsa-project.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: alsa-project/alsa-lib pull request #469 was opened from kv2019i: snd_pcm_avail_delay() is expected to report avail and delay values in atomic fashion. However the function does two separate syscalls and it cannot guarantee the avail value is the same as was used to calculate the delay. This is a problem as the reported delay is always relative to avail frames value. If application (like e.g. alsa_conformance_test) uses snd_pcm_avail_delay() to estimate the effective play position, it can observe bogus delay values (and effective play position going backwards) if snd_pcm_avail_delay() is called during a DMA burst where hw_ptr moves quickly. This commit adds a loop similar to that used in snd_pcm_hw_htimestamp() to wait until we get a stable avail reading, and only then extract the delay. This will avoid bogus values if function is called during DMA bursts. Closes: https://github.com/alsa-project/alsa-lib/issues/468 Request URL : https://github.com/alsa-project/alsa-lib/pull/469 Patch URL : https://github.com/alsa-project/alsa-lib/pull/469.patch Repository URL: https://github.com/alsa-project/alsa-lib