From patchwork Sun Aug 31 16:23:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Patrakov X-Patchwork-Id: 4815401 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 CDD569F375 for ; Sun, 31 Aug 2014 16:48:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B05C20120 for ; Sun, 31 Aug 2014 16:48:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E806420107 for ; Sun, 31 Aug 2014 16:48:15 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B12152654A6; Sun, 31 Aug 2014 18:48:14 +0200 (CEST) Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id D8171261B01; Sun, 31 Aug 2014 18:34:00 +0200 (CEST) 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 92AD2261B01; Sun, 31 Aug 2014 18:33:59 +0200 (CEST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com [209.85.217.169]) by alsa0.perex.cz (Postfix) with ESMTP id DB0AC261B0A for ; Sun, 31 Aug 2014 18:23:58 +0200 (CEST) Received: by mail-lb0-f169.google.com with SMTP id l4so4811408lbv.0 for ; Sun, 31 Aug 2014 09:23:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=1loeuWGL41SqpnFgH26fUFMouiKI+3UaedKJuTT3HPI=; b=RsvC4O9+YFBZgFN6YbGOnYqoVLDaXBdnqal3cWkO+V7zeDYaS3wm36+spCg71Aj38A OzFsnlHZwmtrlSuPh/nhNzTgCfGjF15RbHgYja09SjRGf5rVA2zw0ee6Nxdo/x7YnaZ4 J3AzfLT4Qi95M0Q/OEflR7AL7wVTx9vmVC3XNFLr8WFAuFyvCbgCcb43FEh5v2y0o7Eu Ye2PnhhDCVhBmun4clYzNdQGv5g7bTQawcSqZW8sZT9sAVDNdcna7ncyk2yMz66dzFSf Q5cV+TakViJ7Ljk4KSvkpXgJj+JGnFvrWfi8VKTKLrskDoVOE3OYyX1qmBQst4aZQh4W KHkA== X-Received: by 10.152.87.97 with SMTP id w1mr2799274laz.92.1409502238354; Sun, 31 Aug 2014 09:23:58 -0700 (PDT) Received: from localhost.localdomain (111279190.convex.ru. [82.193.153.141]) by mx.google.com with ESMTPSA id xh2sm9270710lbb.7.2014.08.31.09.23.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 31 Aug 2014 09:23:57 -0700 (PDT) From: "Alexander E. Patrakov" To: alsa-devel@alsa-project.org Date: Sun, 31 Aug 2014 22:23:47 +0600 Message-Id: <1409502227-4505-1-git-send-email-patrakov@gmail.com> X-Mailer: git-send-email 2.1.0 Cc: "Alexander E. Patrakov" Subject: [alsa-devel] [PATCH alsa-lib] pcm: fix snd_pcm_mmap_hw_avail() near the boundary 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-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This function returned incorrect results when hw.ptr was near the boundary and hw.appl_ptr was near zero. Here "incorrect" means "greater than the boundary". The result was incorrect, because it was used as a return value of various *_rewindable() functions and also as the delay for ioplug. Signed-off-by: Alexander E. Patrakov --- src/pcm/pcm_local.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h index 80bbe59..74ebd60 100644 --- a/src/pcm/pcm_local.h +++ b/src/pcm/pcm_local.h @@ -461,13 +461,7 @@ static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_avail(snd_pcm_t *pcm) static inline snd_pcm_sframes_t snd_pcm_mmap_hw_avail(snd_pcm_t *pcm) { - snd_pcm_sframes_t avail; - avail = *pcm->hw.ptr - *pcm->appl.ptr; - if (pcm->stream == SND_PCM_STREAM_PLAYBACK) - avail += pcm->buffer_size; - if (avail < 0) - avail += pcm->boundary; - return pcm->buffer_size - avail; + return pcm->buffer_size - snd_pcm_mmap_avail(pcm); } static inline const snd_pcm_channel_area_t *snd_pcm_mmap_areas(snd_pcm_t *pcm)