From patchwork Thu Sep 3 03:20:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koro Chen X-Patchwork-Id: 7114631 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 23D919F372 for ; Thu, 3 Sep 2015 03:21:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A38A20717 for ; Thu, 3 Sep 2015 03:21:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CB6A420712 for ; Thu, 3 Sep 2015 03:21:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 39758265554; Thu, 3 Sep 2015 05:21:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 3F7C32654F6; Thu, 3 Sep 2015 05:21:41 +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 AE6B226550C; Thu, 3 Sep 2015 05:21:39 +0200 (CEST) Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by alsa0.perex.cz (Postfix) with ESMTP id 34F072654EA for ; Thu, 3 Sep 2015 05:21:31 +0200 (CEST) X-Listener-Flag: 11101 Received: from mtkhts09.mediatek.inc [(172.21.101.70)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1725645889; Thu, 03 Sep 2015 11:21:28 +0800 Received: from mtkslt301 (10.21.14.114) by mtkhts09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 14.3.181.6; Thu, 3 Sep 2015 11:21:27 +0800 Received: by mtkslt301 (Postfix, from userid 11333) id 4A7BF183AC6; Thu, 3 Sep 2015 11:21:27 +0800 (CST) From: Koro Chen To: , , Date: Thu, 3 Sep 2015 11:20:54 +0800 Message-ID: <1441250454-38271-1-git-send-email-koro.chen@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N Cc: alsa-devel@alsa-project.org, linux-mediatek@lists.infradead.org, Koro Chen , srv_heupstream@mediatek.com Subject: [alsa-devel] [RFC PATCH (alsa-lib)] pcm: Modify check condition in snd_pcm_sw_params_set_avail_min 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 When we use a ping-ping buffer in capture, and if hw_ptr reported at IRQ is a little smaller than period_size: |xxxxxxxxxxxxxxxxxxxxxxxxxxxx--|-----------------------------| hw_ptr < period_size This available buffer will not be read since its size is smaller than avail_min (which is set to be period_size), and read thread continues to sleep. If the next hw_ptr is just a little larger than buffer_size, overrun occurs. This could be resolved by setting a small avail_min to kernel, for example, 1, so read thread wakes up and reads every data at IRQ. But current alsa-lib only allows avail_min to be at least period_size. Remove the constraint and only check for zero case. Signed-off-by: Koro Chen --- src/pcm/pcm.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index f5fc728..8492689 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -5958,12 +5958,8 @@ int snd_pcm_sw_params_set_avail_min(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, #endif { assert(pcm && params); - /* Fix avail_min if it's below period size. The period_size - * defines the minimal wake-up timing accuracy, so it doesn't - * make sense to set below that. - */ - if (val < pcm->period_size) - val = pcm->period_size; + if (!val) + val = 1; params->avail_min = val; return 0; }