From patchwork Mon Apr 8 08:55:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Wischer X-Patchwork-Id: 10889033 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 6D6CF17E1 for ; Mon, 8 Apr 2019 08:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F29D28414 for ; Mon, 8 Apr 2019 08:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42F9F28630; Mon, 8 Apr 2019 08:57:22 +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 1EAC428414 for ; Mon, 8 Apr 2019 08:57:20 +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 AF9DD88B; Mon, 8 Apr 2019 10:56:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AF9DD88B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554713837; bh=f5k9zKJ33cIEi0Sc59YXA+ntKMgImgIY/HZ78xlNJhc=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=qxArgaXr2uxTMpvS2Jb1ZtFIaRSbRedkOdtDALZE0NQ8N+k0X5j2lVPgTJbhlffcw 3rRpY7goobSoCMJCQ5y0e6D95ktV3zX/0M8YboS/5JxQsfSpPOUyYzkrYXCFILGb1y ai1pMYUD+hR3OFLRx49TVtyRw6TkX8C5CNAoczZg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0645CF896DB; Mon, 8 Apr 2019 10:56:27 +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 46551F896DD; Mon, 8 Apr 2019 10:56:25 +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 EFC25F89618; Mon, 8 Apr 2019 10:56:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz EFC25F89618 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 643BD3C00D1; Mon, 8 Apr 2019 10:56:18 +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 xRp8Z6f7fa9h; Mon, 8 Apr 2019 10:56:11 +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 A08F03C00C6; Mon, 8 Apr 2019 10:56:11 +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; Mon, 8 Apr 2019 10:56:11 +0200 From: To: , Date: Mon, 8 Apr 2019 10:55:54 +0200 Message-ID: <1554713754-6629-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 v2] 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 --- Hi Takashi, > Why 32? I thought there is also no use case for a period of 1 frame. Therefore I increased it to a 2^n value to also lower the CPU usage in case of null plugin. > Or does it cause a problem? I do not see any issues here. But for example portaudio will automatically choose a period size of 1 frame which will result in a higher CPU load. But anyway I would also be fine with this higher CPU load if you prefer this patch. Best regards Timo src/pcm/pcm_null.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pcm/pcm_null.c b/src/pcm/pcm_null.c index ff61624..1d81548 100644 --- a/src/pcm/pcm_null.c +++ b/src/pcm/pcm_null.c @@ -261,7 +261,17 @@ 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. + */ + err = _snd_pcm_hw_param_set_min(params, SND_PCM_HW_PARAM_PERIOD_SIZE, 1, + 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;