From patchwork Mon Oct 27 12:11:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Henningsson X-Patchwork-Id: 5159861 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8E8CD9F318 for ; Mon, 27 Oct 2014 12:12:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A029F20320 for ; Mon, 27 Oct 2014 12:12:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 68C86201ED for ; Mon, 27 Oct 2014 12:12:11 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 281E02612AC; Mon, 27 Oct 2014 13:12:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 089DB2608D3; Mon, 27 Oct 2014 13:12:06 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A02C42610A6; Mon, 27 Oct 2014 13:12:04 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by alsa0.perex.cz (Postfix) with ESMTP id 495E82608D3 for ; Mon, 27 Oct 2014 13:11:54 +0100 (CET) Received: from hd9483857.selulk5.dyn.perspektivbredband.net ([217.72.56.87] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Xij9M-0002X2-VO; Mon, 27 Oct 2014 12:11:53 +0000 From: David Henningsson To: tiwai@suse.de, perex@perex.cz, alsa-devel@alsa-project.org Date: Mon, 27 Oct 2014 13:11:42 +0100 Message-Id: <1414411902-5335-1-git-send-email-david.henningsson@canonical.com> X-Mailer: git-send-email 1.9.1 Cc: David Henningsson Subject: [alsa-devel] [PATCH] pcm: Fix snd_pcm_avail_update description X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP While reading alsa-lib code, I discovered that snd_pcm_avail_update does require a user-kernel context switch: snd_pcm_avail_update() -> snd_pcm_hw_avail_update() -> sync_ptr() -> sync_ptr1() -> ioctl() The documentation says it does not, so let's fix the documentation. Signed-off-by: David Henningsson --- src/pcm/pcm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index 4a7be6c..e57e362 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -403,10 +403,12 @@ The function #snd_pcm_avail_update() updates the current available count of samples for writing (playback) or filled samples for reading (capture). This call is mandatory for updating actual r/w pointer. Using standalone, it is a light method to obtain current stream position, -because it does not require the user <-> kernel context switch, but the value -is less accurate, because ring buffer pointers are updated in kernel drivers +because while it does require a user <-> kernel context switch, the value is +just copied from the kernel, and not updated by synchronously asking the hardware +about its current position. The ring buffer pointers are updated in kernel drivers only when an interrupt occurs. If you want to get accurate stream state, -use functions #snd_pcm_avail(), #snd_pcm_delay() or #snd_pcm_avail_delay(). +use functions #snd_pcm_avail(), #snd_pcm_delay(), #snd_pcm_avail_delay() or +#snd_pcm_status().

The function #snd_pcm_avail() reads the current hardware pointer