From patchwork Fri Apr 5 14:09:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Wischer X-Patchwork-Id: 10887485 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 5D5B31669 for ; Fri, 5 Apr 2019 14:11:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 403B028A92 for ; Fri, 5 Apr 2019 14:11:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34AC228A9B; Fri, 5 Apr 2019 14:11:20 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3BA0C28A92 for ; Fri, 5 Apr 2019 14:11:19 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 391351639; Fri, 5 Apr 2019 16:10:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 391351639 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554473477; bh=9NzXHUvxhXOkfGus2jkp6MR5kCCa8txmtgVj/C9BLPY=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=t5n4UzpqGA6CV2pknX01OlUwwo+kO4vg13lTYbL0VlGTw5Ub1GdO9/pzzhFenyVo6 gYfI2D1xpKag/4mkU7AEu0nt3pfNEuTXNtE+hYbQ3QQfZOBWhg0hMS64F7ePCsX8Rf 4MWGd20JlFDhfsT3Fd9J3aNGKEPXEZaVi36UUeIk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 881BCF89615; Fri, 5 Apr 2019 16:10:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id DA31CF8962D; Fri, 5 Apr 2019 16:10:24 +0200 (CEST) Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6773DF80792; Fri, 5 Apr 2019 16:10:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6773DF80792 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 7CA203C00C5; Fri, 5 Apr 2019 16:10:17 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hmqwP7O1tB5J; Fri, 5 Apr 2019 16:10:10 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 67D333C00C4; Fri, 5 Apr 2019 16:10:10 +0200 (CEST) Received: from vmlxhi-087.adit-jv.com (10.72.93.172) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 5 Apr 2019 16:10:09 +0200 From: To: , Date: Fri, 5 Apr 2019 16:09:53 +0200 Message-ID: <1554473393-5757-1-git-send-email-twischer@de.adit-jv.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.72.93.172] Cc: Timo Wischer , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH] pcm: null: Do not allow a period size of 0 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" X-Virus-Scanned: ClamAV using ClamSMTP From: Timo Wischer Some applications do not expect that get_period_size_min() could return 0. Therefore these applications cannot use the null plugin without this patch. Due to there is no use case for having a period size of 0 this patch disallows a period size of 0 when using the null plugin. Signed-off-by: Timo Wischer --- src/pcm/pcm_null.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index ff61624..c95fad8 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -261,7 +261,18 @@ static snd_pcm_sframes_t snd_pcm_null_mmap_commit(snd_pcm_t *pcm, static int snd_pcm_null_hw_refine(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_hw_params_t *params) { - int err = snd_pcm_hw_refine_soft(pcm, params); + int err; + + /* Do not return a period size of 0 because for example portaudio cannot + * handle it. In addition such small buffers would only increase the CPU + * load but there is no benefit when throwing the samples anyway away. + */ + err = _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_PERIOD_SIZE, + 32, 0); + if (err < 0) + return err; + + err = snd_pcm_hw_refine_soft(pcm, params); params->info = SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID | SND_PCM_INFO_RESUME | SND_PCM_INFO_PAUSE; params->fifo_size = 0;