From patchwork Wed Aug 22 15:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Biehl Pasquali X-Patchwork-Id: 10573011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B48CB5A4 for ; Wed, 22 Aug 2018 15:20:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1A8B2B8A5 for ; Wed, 22 Aug 2018 15:20:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95C5E2B8B2; Wed, 22 Aug 2018 15:20:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93C3C2B8A5 for ; Wed, 22 Aug 2018 15:20:03 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4A74D2676C7; Wed, 22 Aug 2018 17:04:13 +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 54C892676C9; Wed, 22 Aug 2018 17:04:10 +0200 (CEST) Received: from mail-qt0-f181.google.com (mail-qt0-f181.google.com [209.85.216.181]) by alsa0.perex.cz (Postfix) with ESMTP id 293B3267663 for ; Wed, 22 Aug 2018 17:04:07 +0200 (CEST) Received: by mail-qt0-f181.google.com with SMTP id g44-v6so1725523qtb.12 for ; Wed, 22 Aug 2018 08:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=YQ3ShXdCFIpEKvhTrYV3MGXF/H6cH+OeI9+QeILSUlI=; b=Ve9Vqam2o9fKsBpFKIXkX6mFKWDNVvMi/nGOrhDIt1Hps58J2sp3MdMGH5whRJL4uf Q9RNdTPCl/QskUpkyMQZz0RHfNh9GE3YL6Aqas4JwuLDm0Pr/yMB34DQzLl+V9A19HaV pP+WREH17HOB1IvQAB4vxo5GjLpIfqOoT7LgcFOnbr5ZFZ50KvE0g9hXEYNCqdySuAKO f+Fbm3lKmD+vSXbvu8tuwGIyA7u+4YhuUm/9zmsONbqnbZi0O2gJjI8YNAx6L8xEG6Uc aTFb39WNgR85yerjzZkCDzbfsVC2j34t6tlxuE/GtL+BdNn5X7kLk2f9NsjrzUbiY/tl EvzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=YQ3ShXdCFIpEKvhTrYV3MGXF/H6cH+OeI9+QeILSUlI=; b=HpDas3ksgcFd2i5+1zG6oTvnyxDXeGby7y/s9U8lPsxffnrm4uK3Eal+k+04wJBWqQ Eb5kANHogBZaGj9y5h4Y0XFD+CH1YCoV3+x4gzml7r08CVDsvM5US4eDFRSZPlpwbrhW HIXACtgM4yydV/jojd74FLXQ2lfy8aBFpcmxXNTP31SsoUK+NFzurCCHGVtKbtQ4fdRq +gpLtUREYcN32J/iK3VgqJjz5LopjM0WMIicx3ibp5NYv1/N9HthoyCfx8eaaM2XdwSu ZAUjLQDRHhp3cZCZueBU4DAJeAApLkungE17kVAWIpLrsV54ZMmxizL20HukpzvtMxkb lWWg== X-Gm-Message-State: APzg51DZSfs8LOMKgCI21N0HHIAdLS2nKwkf4Z4hWqWsOl5/+a5t01M1 keN+LmweSspTcfjs9OmYPBA= X-Google-Smtp-Source: ANB0VdaoCnydrQckflAD/smWlwv6GQ1zQiIzC2SSTYuaeTHRhfuYHodzf1xukebisouLc1Ft1d4Hsw== X-Received: by 2002:a0c:818b:: with SMTP id 11-v6mr12535294qvd.129.1534950246704; Wed, 22 Aug 2018 08:04:06 -0700 (PDT) Received: from localhost.localdomain ([201.37.66.59]) by smtp.gmail.com with ESMTPSA id v13-v6sm1048487qtg.82.2018.08.22.08.04.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 08:04:05 -0700 (PDT) Date: Wed, 22 Aug 2018 12:03:59 -0300 From: Ricardo Biehl Pasquali To: tiwai@suse.de Message-ID: <20180822150359.GA12976@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Cc: alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH v2] ALSA: pcm: Return 0 when size < start_threshold in capture 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP In __snd_pcm_lib_xfer(), when capture, if state is PREPARED and size is less than start_threshold nothing can be done. As there is no error, 0 is returned. Signed-off-by: Ricardo Biehl Pasquali --- version 2: The code was not changed. Just resubmitting to follow the rules from Documentation/process/submitting-patches.rst. --- pcm_lib.c.orig 2018-08-21 15:31:54.457405053 -0300 +++ pcm_lib.c 2018-08-21 15:56:01.264549084 -0300 @@ -2125,7 +2125,7 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(str pcm_transfer_f transfer; bool nonblock; bool is_playback; - int err; + int err = 0; err = pcm_sanity_check(substream); if (err < 0) @@ -2173,11 +2173,15 @@ snd_pcm_sframes_t __snd_pcm_lib_xfer(str goto _end_unlock; if (!is_playback && - runtime->status->state == SNDRV_PCM_STATE_PREPARED && - size >= runtime->start_threshold) { - err = snd_pcm_start(substream); - if (err < 0) + runtime->status->state == SNDRV_PCM_STATE_PREPARED) { + if (size >= runtime->start_threshold) { + err = snd_pcm_start(substream); + if (err < 0) + goto _end_unlock; + } else { + /* nothing to do */ goto _end_unlock; + } } runtime->twake = runtime->control->avail_min ? : 1;