From patchwork Sat Sep 13 18:30:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Patrakov X-Patchwork-Id: 4899921 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 AD1C69F32B for ; Sat, 13 Sep 2014 18:29:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6265A201C8 for ; Sat, 13 Sep 2014 18:33:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 22B71201F4 for ; Sat, 13 Sep 2014 18:33:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 2698626577C; Sat, 13 Sep 2014 20:33:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3B86B26548D; Sat, 13 Sep 2014 20:31:08 +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 5D4A2265335; Sat, 13 Sep 2014 20:31:03 +0200 (CEST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com [209.85.215.45]) by alsa0.perex.cz (Postfix) with ESMTP id C24792625C4 for ; Sat, 13 Sep 2014 20:30:55 +0200 (CEST) Received: by mail-la0-f45.google.com with SMTP id b17so2663351lan.32 for ; Sat, 13 Sep 2014 11:30:55 -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:in-reply-to:references; bh=uQ44aQpvXXXGh3He5I8B+SOjJ6lzO5jV4diR0+oluHM=; b=hqzMaI73qq4cMHPQ7PGWuPGrdKufZO4igibEckF08/96wBmw4NHP63sB2KGLePb7RP uDcrME6jyS4R/2sYmIld+S8FuzoHqCWMW94As8ybL7Po7JQLNtpkaxhp09Q9ADf0o9Fe muzRSl9oNUhXVxBQna/om/W9qktybH/KnYN1sD4s2Z7d0PP92sj9+t+rpvR2KUIhUnID ugnWynHQUPkqDsHzuTFGg8FxC4yYtXOTZPwptSFeHAmMelX7jIWzUddRLIdTYJt2xB/H Sr7cJLWqLvLzUIjhEuRIayjGUMUhC0Vgb26R9/warZJU6x6asb8upfArPVAH3yf7HRLO lC8w== X-Received: by 10.112.19.70 with SMTP id c6mr16840887lbe.20.1410633055325; Sat, 13 Sep 2014 11:30:55 -0700 (PDT) Received: from localhost.localdomain (111279190.convex.ru. [82.193.153.141]) by mx.google.com with ESMTPSA id pc2sm2567718lbb.5.2014.09.13.11.30.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Sep 2014 11:30:54 -0700 (PDT) From: "Alexander E. Patrakov" To: alsa-devel@alsa-project.org Date: Sun, 14 Sep 2014 00:30:18 +0600 Message-Id: <1410633021-20395-7-git-send-email-patrakov@gmail.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1410633021-20395-1-git-send-email-patrakov@gmail.com> References: <1410633021-20395-1-git-send-email-patrakov@gmail.com> Cc: tiwai@suse.de, clemens@ladisch.de, "Alexander E. Patrakov" Subject: [alsa-devel] [PATCH 6/9] rate: handle negative values from snd_pcm_mmap_playback_hw_avail 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 Such negative returns are possible during an underrun if xrun detection is disabled. So, don't store the result in an unsigned variable (where it will overflow), and postpone the trigger in such case, too. Signed-off-by: Alexander E. Patrakov --- The patch is only compile-tested and the second hunk may well be wrong. There are also similar issues in pcm_share.c, but, as I don't completely understand the code there and cannot test that plugin at all due to unrelated crashes, there will be no patch from me. src/pcm/pcm_rate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index b436a8e..736d558 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -1058,7 +1058,7 @@ static snd_pcm_state_t snd_pcm_rate_state(snd_pcm_t *pcm) static int snd_pcm_rate_start(snd_pcm_t *pcm) { snd_pcm_rate_t *rate = pcm->private_data; - snd_pcm_uframes_t avail; + snd_pcm_sframes_t avail; if (pcm->stream == SND_PCM_STREAM_CAPTURE) return snd_pcm_start(rate->gen.slave); @@ -1069,7 +1069,7 @@ static int snd_pcm_rate_start(snd_pcm_t *pcm) gettimestamp(&rate->trigger_tstamp, pcm->tstamp_type); avail = snd_pcm_mmap_playback_hw_avail(rate->gen.slave); - if (avail == 0) { + if (avail <= 0) { /* postpone the trigger since we have no data committed yet */ rate->start_pending = 1; return 0;