From patchwork Thu Mar 11 05:21:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1708C433DB for ; Thu, 11 Mar 2021 05:24:09 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D7D164FC0 for ; Thu, 11 Mar 2021 05:24:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D7D164FC0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 D6DB616FA; Thu, 11 Mar 2021 06:23:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D6DB616FA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440246; bh=IgEhd8gaWjpcjoO0iH9sBrM2odmhhyld8wg3/H9tW8o=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Dwn3EtxxtUey+mklCGZWuGvD0XG27rfnf5CtFhpKVNv/IcoaAujf24vyTul9eMxKl gTSlj6Lb2hrIAldbtnKgVNBzl+YrMwqMwVMuafvHETUTUKhXbL7kdVpOiisKLS58PL ZlEoQinMuIetYLJheKKaU96ftUI4ATxiHxH4Q+tA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2F339F804AC; Thu, 11 Mar 2021 06:22:19 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BA9A8F804AC; Thu, 11 Mar 2021 06:22:16 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E6E2AF8015B for ; Thu, 11 Mar 2021 06:21:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E6E2AF8015B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="gxJiz9bB"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rg6mQtUT" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1945A2FA0; Thu, 11 Mar 2021 00:21:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:21:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=4/hffh3FPz/3y LeRfHga+JBwUjSKdCrIAe+KpMYAOMs=; b=gxJiz9bBMoHCP5AW64nWC1bsEDJOG hT6b/8TIBp0GqIZjrvya4yj024pm0wH2Y3kIpOvLxaj0WPjK+ZxlWVLnbeGYWP3D D4B4qVfMVMTRBRzD3WWWFxQstyq+fZnr+cAgKgOx0zZpM90MzQ4xX/nuHLBMOBH3 1KUnaQGkyr8z43k2LgXz+tvzdY2Y4DdWW1u13qxEzi70p2fttPw+qf+J7fwW2Fwq nqEo6xw5gtt9hWTyltnGmwnegYaqvrOJ/b5HGCKb1EhzJQD5FTTQOWpGMQZX4sav tyVITPEJrRO6coiMyPbyYmPS55cryDPJzX0Q8BMHIVE9C8ZfYdshN5M7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=4/hffh3FPz/3yLeRfHga+JBwUjSKdCrIAe+KpMYAOMs=; b=rg6mQtUT E6J0aobkqtfS6NT4oQC5qfi8Ir4DEHzWWBzsdlLTlGk9OtHb+ZWagXh4uqMRJiNI mUcKlDsHJZi+a0ESFGGQkH5LSbVOi064fQ1VAkY+xesMvZSXNtwdLihN5eGYjFRZ pTa0et6WEJzhDNTXrYSvsa6sD+g8AjPMzUd5oIE+iXMDIxod8Zt3KmswKfTGqDjS lkWjiF0DivpqnbK0xhSUbUD/3d+xi2i0Ktc5jHnZ+wlBf9nNI6Jh8+fXMXYYJtti eO2RZC23wMqUpdlkR0nfFcfzGGdJK69jAQQ6nTyod7E/vX8hyVTfyTmba/Bvf3io +cfW/6Io/UL7FA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id AE5A224005A; Thu, 11 Mar 2021 00:21:51 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 01/14] axfer: minor code arrangement for container module in a point of nonblocking flag Date: Thu, 11 Mar 2021 14:21:32 +0900 Message-Id: <20210311052146.404003-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" In internal container module, any file descriptor is expected as non-blocking mode. Current implementation distinguish the case of standard input and output from the case to open actual file since O_NONBLOCK is used for the latter case. However, in both cases, fcntl(2) is available to set non-blocking mode to the file descriptor. This commit arranges to use fcntl(2) for both cases. Signed-off-by: Takashi Sakamoto --- axfer/container.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/axfer/container.c b/axfer/container.c index 566acd0..8733ff7 100644 --- a/axfer/container.c +++ b/axfer/container.c @@ -176,16 +176,17 @@ int container_parser_init(struct container_context *cntr, "should be referred instead.\n"); return -EIO; } - err = set_nonblock_flag(cntr->fd); - if (err < 0) - return err; cntr->stdio = true; } else { - cntr->fd = open(path, O_RDONLY | O_NONBLOCK); + cntr->fd = open(path, O_RDONLY); if (cntr->fd < 0) return -errno; } + err = set_nonblock_flag(cntr->fd); + if (err < 0) + return err; + // 4 bytes are enough to detect supported containers. err = container_recursive_read(cntr, cntr->magic, sizeof(cntr->magic)); if (err < 0) @@ -260,17 +261,17 @@ int container_builder_init(struct container_context *cntr, "should be referred instead.\n"); return -EIO; } - err = set_nonblock_flag(cntr->fd); - if (err < 0) - return err; cntr->stdio = true; } else { - cntr->fd = open(path, O_RDWR | O_NONBLOCK | O_CREAT | O_TRUNC, - 0644); + cntr->fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); if (cntr->fd < 0) return -errno; } + err = set_nonblock_flag(cntr->fd); + if (err < 0) + return err; + builder = builders[format]; // Allocate private data for the builder. From patchwork Thu Mar 11 05:21:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 398761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53C35C433E0 for ; Thu, 11 Mar 2021 05:23:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A0A764FBB for ; Thu, 11 Mar 2021 05:23:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A0A764FBB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 BC0621704; Thu, 11 Mar 2021 06:23:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BC0621704 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440232; bh=nKJpAWbmNGAWS0PnclTCWRar0su+QPYXRETlnt3lbx8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=r2iODI/XaPYg6ODuxGTJualAM1Zhza6nVyDzbgeZxI0b3GMbk0kN5UmwBxhD0nBZF MliWIjnKAOkHe6544sWZX+B29Ab4z2dKCFMw78DNxZx0+iF3KTbhK64EULPt8ZWYt1 G+23OPyViV5R3lEyKFm6xjpQsjqIF5xoOE2ZG8Xg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D6300F80424; Thu, 11 Mar 2021 06:22:12 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DBB76F802E7; Thu, 11 Mar 2021 06:22:05 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E6E9EF80227 for ; Thu, 11 Mar 2021 06:21:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E6E9EF80227 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="2dG7dRSE"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="vCQ7AmUJ" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 671412F9D; Thu, 11 Mar 2021 00:21:54 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:21:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=r9NmmVXj2X/lM wdRk/iv7M6mcJV1mKAwq4IuCDRDv5U=; b=2dG7dRSEnQrZ4IbLKfW+xogCGNc9L ZEc3zC4pEbXbSt+H0rwd/7hh2S6jOO3u56NTpE1nrM239eIRa9u/KesG5oSkXK9D Je2mAqrLBOHsIos9IQ0cZs45eAaPerEQcV4igseFS/msKS0sjXDfR9ssjFS6v82P urg/f37CdoiLNjOzLZDS6R0wAcUpR7xqq0tG4+2s/++xeSjDWppCzqwHnYA9h0HD C38dBnxqRWOpZzr/nY0sF1yJEcYePYCMdH1t/Q9bgbl1b2H0r8sTd9xZkw4/qSnE LJpN9cbjZamOmBWBCDEp+qhMnA5yKD5w4yuURFzgRT/1ncOGpOiYTsSJw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=r9NmmVXj2X/lMwdRk/iv7M6mcJV1mKAwq4IuCDRDv5U=; b=vCQ7AmUJ cD076+gCySBw09M34TLx08ZghUXba4xQBir1YK+1vpJ0/2++uEJFcGpkTD3moh+J Uhe5X5R3BFZ9v9eI0+t/RM2+yP3rOM/TJPzmkKrNloRbOjEcs91DkgjGcepKOckI 1vsis7uUlV2YcycadPXeNtvwyb26n0pKk8BRb4CzfZLMRYm/yZYuHcuDY33HQ+AQ j3J5FdWPAu08JZ+2yLxYmpwfSVnm5clRgykhbVi6kPMJus5R9aoNkkm5hM1js0xH wN9Ww6gE0jtm//lk8Lm+qOXVTVPXqBlfo5fxSy8X5jZs1K/023TRHaHGHut1T9YE g3HPJNE2rMEcDw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 00C8B240054; Thu, 11 Mar 2021 00:21:52 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 02/14] axfer: minor code arrangement in a point of stdio detection Date: Thu, 11 Mar 2021 14:21:33 +0900 Message-Id: <20210311052146.404003-3-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" Current implementation sets stdio member in a condition branch, however it's convenient to set it always regardless of any condition. This commit arranges assignment to the member. Signed-off-by: Takashi Sakamoto --- axfer/container.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/axfer/container.c b/axfer/container.c index 8733ff7..fb35eba 100644 --- a/axfer/container.c +++ b/axfer/container.c @@ -169,6 +169,14 @@ int container_parser_init(struct container_context *cntr, // Open a target descriptor. if (!strcmp(path, "-")) { cntr->fd = fileno(stdin); + } else { + cntr->fd = open(path, O_RDONLY); + if (cntr->fd < 0) + return -errno; + } + + cntr->stdio = (cntr->fd == fileno(stdin)); + if (cntr->stdio) { if (isatty(cntr->fd)) { fprintf(stderr, "A terminal is referred for standard input. " @@ -176,11 +184,6 @@ int container_parser_init(struct container_context *cntr, "should be referred instead.\n"); return -EIO; } - cntr->stdio = true; - } else { - cntr->fd = open(path, O_RDONLY); - if (cntr->fd < 0) - return -errno; } err = set_nonblock_flag(cntr->fd); @@ -254,6 +257,14 @@ int container_builder_init(struct container_context *cntr, return -EINVAL; if (!strcmp(path, "-")) { cntr->fd = fileno(stdout); + } else { + cntr->fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (cntr->fd < 0) + return -errno; + } + + cntr->stdio = (cntr->fd == fileno(stdout)); + if (cntr->stdio) { if (isatty(cntr->fd)) { fprintf(stderr, "A terminal is referred for standard output. " @@ -261,11 +272,6 @@ int container_builder_init(struct container_context *cntr, "should be referred instead.\n"); return -EIO; } - cntr->stdio = true; - } else { - cntr->fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (cntr->fd < 0) - return -errno; } err = set_nonblock_flag(cntr->fd); From patchwork Thu Mar 11 05:21:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397600 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C4DAC433DB for ; Thu, 11 Mar 2021 05:23:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80AB964FC9 for ; Thu, 11 Mar 2021 05:23:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80AB964FC9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 2293216F7; Thu, 11 Mar 2021 06:22:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2293216F7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440180; bh=fXzADS1kq2dZtVPzavTTOVod7u+a/ibR0BQErc0xOsk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EIA5piyjzuWjcMB6xvUqFBOitpAs9TIZX8XHb9IYYtu7R3fKTOkwOyUdoRIfIEXhz SPxSrLnmbpYvr6nQV+dj9WYgr+UwqFYD08HKszo4RrL9sAM9tfQI1/QQBCR9iVYTCm Zkd/jvhw3eZkxIvg3zWfD9GRh10SBrkvGNzX7lZE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 56A06F802E7; Thu, 11 Mar 2021 06:22:09 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1DB14F8019B; Thu, 11 Mar 2021 06:22:05 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 788D8F8019B for ; Thu, 11 Mar 2021 06:21:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 788D8F8019B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="EcMimhCj"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qDNZ9MAa" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C2D1E2FA6; Thu, 11 Mar 2021 00:21:55 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:21:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=woD/s1xL3qGTy n5onCrVICODUISrJwFGDBfJAjXoCcg=; b=EcMimhCj5GzcFF+YsySRu70XPzjad 4NtsMks9uHNMnVYFDPOOiQOlRg5m6uKZOp457T+GYDS9IqQDo5WIf8YUz3qD6Fhl a/1RtKsl0OXHFJjRKUYXdz6X4Yp/+nSlvtF0piBnMq+wYm8s/XdUXdaJUsN37f1H +lv81a3twzlGbwoBEp/qxvvrTRqbkcOGwMFYNIktPiDkw2TrVI6dWdAxpZlQIPuH A+lM5szcHL4cEBr+oKIkIiRa98Jt6aqYqSAwRKBoxoHoeTl9G4OQH4pbZCb4v/pg kW+tKIH3raj8DY7Ipn9Ek+BEdInBzsfr7wPreJXh3M2OXnUJdvybFEGVQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=woD/s1xL3qGTyn5onCrVICODUISrJwFGDBfJAjXoCcg=; b=qDNZ9MAa wdnJIcIdkHTNZNcmN6NMI8cl7DIilBHS6Tn69EjJ+MgyASH7V8mcw+kvZDP6xDIO JEwwHCqEv3dySEmiagWixtnJlbgOQFhgUphzInL3O549HlpyPhqNwugU2iXbMT1V zpTw9Sa+ir5F9vDHHSE2ANY2u1ieGB37JCKr/+s5wsHzfqHvOl8YkU4mxsoNVS50 g4HtgUH7YcMLns2INqDXkZV7nl0dNii8X1c0J0BfnCdRpxrmCjmdknMeuypX+cO0 5MYOKBpsjzY47WmDcB50FbwRVZKE+iHnrg2/NuGSm9VZlLh1YWF85G/Fwlrj7Jku ryDyrMTtUIGFBQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 5988F24005D; Thu, 11 Mar 2021 00:21:54 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 03/14] axfer: minor code arrangement in a point of opened file descriptor Date: Thu, 11 Mar 2021 14:21:34 +0900 Message-Id: <20210311052146.404003-4-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This commit arranges assignment to fd member after checking file descriptor. Signed-off-by: Takashi Sakamoto --- axfer/container.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/axfer/container.c b/axfer/container.c index fb35eba..b4646b9 100644 --- a/axfer/container.c +++ b/axfer/container.c @@ -151,6 +151,7 @@ int container_parser_init(struct container_context *cntr, [CONTAINER_FORMAT_AU] = &container_parser_au, [CONTAINER_FORMAT_VOC] = &container_parser_voc, }; + int fd; const struct container_parser *parser; unsigned int size; int i; @@ -168,12 +169,13 @@ int container_parser_init(struct container_context *cntr, // Open a target descriptor. if (!strcmp(path, "-")) { - cntr->fd = fileno(stdin); + fd = fileno(stdin); } else { - cntr->fd = open(path, O_RDONLY); - if (cntr->fd < 0) + fd = open(path, O_RDONLY); + if (fd < 0) return -errno; } + cntr->fd = fd; cntr->stdio = (cntr->fd == fileno(stdin)); if (cntr->stdio) { @@ -239,6 +241,7 @@ int container_builder_init(struct container_context *cntr, [CONTAINER_FORMAT_VOC] = &container_builder_voc, [CONTAINER_FORMAT_RAW] = &container_builder_raw, }; + int fd; const struct container_builder *builder; int err; @@ -256,12 +259,13 @@ int container_builder_init(struct container_context *cntr, if (path == NULL || *path == '\0') return -EINVAL; if (!strcmp(path, "-")) { - cntr->fd = fileno(stdout); + fd = fileno(stdout); } else { - cntr->fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (cntr->fd < 0) + fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (fd < 0) return -errno; } + cntr->fd = fd; cntr->stdio = (cntr->fd == fileno(stdout)); if (cntr->stdio) { From patchwork Thu Mar 11 05:21:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDA9BC433E0 for ; Thu, 11 Mar 2021 05:24:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2656864EB7 for ; Thu, 11 Mar 2021 05:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2656864EB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 88036171D; Thu, 11 Mar 2021 06:23:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 88036171D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440287; bh=omNqrkhXKMmDJ7HPC1+ZXrwLcWJXalreHhkEzTR2tV8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MdaRF+Rb8A6U4zQLiqQL+jvAOWCsLnqboimeMtZEFredR0kYLf6UMYXlPSiHEZFm+ vXsCK/O48gM3++JFnH+Zfof8TlzIyOKoPloZB/czyRSA76w6ZONRJis6FzJr29pndr FWLky+slHx6Wy0SMjRF/0dK4Ybx+kegi081xrUWI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7A0E1F804B2; Thu, 11 Mar 2021 06:22:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A0C3F804B2; Thu, 11 Mar 2021 06:22:22 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E8ACAF80256 for ; Thu, 11 Mar 2021 06:21:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E8ACAF80256 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="R5fjnfdm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="oPjuj6J5" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 2EE532FAC; Thu, 11 Mar 2021 00:21:57 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:21:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=8uruRkbmDFcVY YXq0kgCeHF4CDUTPNjx2foUT+6bpN8=; b=R5fjnfdm0CXQdBINx1L+ZFkJ+e4/P ncTcejBn6mYXgQduAP/lbseMl3THra9U+5EU/1CnJNurLVuk8uvLwx4QkazJrPnO cbcRUnHgAaQzZAi5Jd3dggneu8pcO3mdxYIYap2m7rlY52MOXV3Gu8X6hCK6O18+ XV7vilzhVC1AFCJ0csEijptUOVs8OFgvdfLkywsmwlpvBxiZmVLwa4+2hlA/FGdA iCafEqO8gvdwGAa/hyULBiwuEtsRFxhLczuDE5P3gr9C9WaeQ+gHXR3vqCrmvC2b 7T/jz3/bgPJZVkcmVffFijHDPTlugp6j7D35Od0v9g+rHo+JExnPxA4Ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=8uruRkbmDFcVYYXq0kgCeHF4CDUTPNjx2foUT+6bpN8=; b=oPjuj6J5 cEfwd8gu41Oj7gEFmLkmkMdXBSwr+grsyED8WRbSjvsnKOz2gT5LetfPeAyriQio 6md2tZMRwPqxEg4Yz81/0THCigmHMr9RBBaWOf3OPhkhfEx9zpDINzKa4s1A9RQy NCr5xXYMQAh4hsTTSrBf6UAzYm++Sm+OCVsYYwkQNKXBrdGKbrkAsjC73vINLEJg U2qAP4Fl1NumqGLHs+mx8EuU3YmFvhakr8NCYrpKixsVBGNUtZneoIcY1Yke2DxE HTACIjjcEb5ag0TqxZZnB+1foxawo/t1WMZ8R5f8qODkgjDM8OrMIC5a23PTpn69 MeazUHGNQmc6CA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id BDEAF24005A; Thu, 11 Mar 2021 00:21:55 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 04/14] axfer: minor code arrangement to allocate containers Date: Thu, 11 Mar 2021 14:21:35 +0900 Message-Id: <20210311052146.404003-5-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This commit unifies duplicated code to allocate for container structure. Signed-off-by: Takashi Sakamoto --- axfer/subcmd-transfer.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/axfer/subcmd-transfer.c b/axfer/subcmd-transfer.c index 8746e6f..6962208 100644 --- a/axfer/subcmd-transfer.c +++ b/axfer/subcmd-transfer.c @@ -146,6 +146,16 @@ static int context_init(struct context *ctx, snd_pcm_stream_t direction, return xfer_context_init(&ctx->xfer, xfer_type, direction, argc, argv); } +static int allocate_containers(struct context *ctx, unsigned int count) +{ + ctx->cntrs = calloc(count, sizeof(*ctx->cntrs)); + if (ctx->cntrs == NULL) + return -ENOMEM; + ctx->cntr_count = count; + + return 0; +} + static int capture_pre_process(struct context *ctx, snd_pcm_access_t *access, snd_pcm_uframes_t *frames_per_buffer, uint64_t *total_frame_count) @@ -164,10 +174,9 @@ static int capture_pre_process(struct context *ctx, snd_pcm_access_t *access, return err; // Prepare for containers. - ctx->cntrs = calloc(ctx->xfer.path_count, sizeof(*ctx->cntrs)); - if (ctx->cntrs == NULL) - return -ENOMEM; - ctx->cntr_count = ctx->xfer.path_count; + err = allocate_containers(ctx, ctx->xfer.path_count); + if (err < 0) + return err; if (ctx->cntr_count > 1) channels = 1; @@ -212,10 +221,9 @@ static int playback_pre_process(struct context *ctx, snd_pcm_access_t *access, int err; // Prepare for containers. - ctx->cntrs = calloc(ctx->xfer.path_count, sizeof(*ctx->cntrs)); - if (ctx->cntrs == NULL) - return -ENOMEM; - ctx->cntr_count = ctx->xfer.path_count; + err = allocate_containers(ctx, ctx->xfer.path_count); + if (err < 0) + return err; for (i = 0; i < ctx->cntr_count; ++i) { snd_pcm_format_t format; From patchwork Thu Mar 11 05:21:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 398760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4DA2C433DB for ; Thu, 11 Mar 2021 05:24:41 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C313764FC9 for ; Thu, 11 Mar 2021 05:24:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C313764FC9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 22C7016F9; Thu, 11 Mar 2021 06:23:49 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 22C7016F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440279; bh=Y3cOTsRyyvZlnIHXYFniuOuRTCdb2iDsPPWkLtjSWjw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lz+K2fkMD94WqdZ1fTy+Fru+GdNfLUQY6tQ6FPkxQI0Po0puyISdUqEJXqCQy4W1Y Po9leM9AnBQadJk/KiVT/HISkcvFM5j1pff2pULk7CSfBRea6VGEP6hq3atGuiQgOh jefUhcuh6mprDs6YS+05dzuoIsvvWJ8Fhw1C4yGE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5B61CF80256; Thu, 11 Mar 2021 06:22:22 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9092AF804B1; Thu, 11 Mar 2021 06:22:20 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 7E092F8025A for ; Thu, 11 Mar 2021 06:22:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7E092F8025A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="tzpiksJ9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="PDX3UWK9" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 84F0B2FB1; Thu, 11 Mar 2021 00:21:58 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:21:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=HvJAd77eOJTuR hKUuKWovywlFpayPVJJGRJkfS7k9Pg=; b=tzpiksJ9EhJX+9yJV2DFgB1ERjBa9 GJVg/UdVX7/py9h4XzrmLAQADyBc4hkwjAYIAsfhwKkL5/ChIcNBaRd2p1vNPcDL IVl8HlL1dIzDTcOxfxb8+3VqVOGOPAUA47MIVy43CyjGE3SF4SvuCvaYjjYLJ0Cb xfQBk6JiVPs9xS0aTvjZVllSo3FptH11lsDaHSL7dI8Mgu38t8tgYvfI/rRbvPrw BVkKf+xwwT82HN84LYe6ioT26fdwpf9eFCMxvN8HWLweXobHAy2Qts5bubMebcll WFB8q7UidNrivL2QxcHX8Wc3tg0I+s3VXgO18alDjiaSTKmgCCfPn3CVw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=HvJAd77eOJTuRhKUuKWovywlFpayPVJJGRJkfS7k9Pg=; b=PDX3UWK9 XhBqcfGtqp/FQkUXlA52/sG/1Ym9+oZ4CHKL5djrh+phwOX+KyeRWR7FC22z1nEX VUCSau1lOSKbftbWKa9i6cMTlWV+ZA+/HcuDzDiujzFNj6k7oEAI9v9YZfmtiNzb AZg7lrnvTqtzGEodjJIbsAJYyEvQlqoBLkQrny7pegFUs8Y1Eo0Xw6lL9jkmIBHe 06JTqHxigvE/st5DLG0wWW/Dg15D5AbXaoYXz+ecmUUtf95VAfn/J8+XQoKeO+Ca 8CWhhKThzmfIhfgg3qeXs4UPISl8xyIISmyBiB2jnLSpaUhmjb9LuqDOAQOygD5A tcKcSAkqhRTGew== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 18D43240057; Thu, 11 Mar 2021 00:21:56 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 05/14] axfer: open file descriptor outside of container module Date: Thu, 11 Mar 2021 14:21:36 +0900 Message-Id: <20210311052146.404003-6-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" Internal container module operates file descriptor to media file. For this purpose, the structure has fd member and any file operation is done internally. However, the case to use special file descriptor such as memfd requires to maintain file descriptor externally. This commit opens file descriptor outside of container module. The internal APIs to initialize container get an argument for the file descriptor instead of file path. Signed-off-by: Takashi Sakamoto --- axfer/container.c | 35 ++++++----------------------------- axfer/container.h | 9 ++++----- axfer/subcmd-transfer.c | 26 ++++++++++++++++++++++---- axfer/test/container-test.c | 12 ++++++++++-- axfer/test/mapper-test.c | 19 ++++++++++++++----- 5 files changed, 56 insertions(+), 45 deletions(-) diff --git a/axfer/container.c b/axfer/container.c index b4646b9..255f12c 100644 --- a/axfer/container.c +++ b/axfer/container.c @@ -143,23 +143,21 @@ static int set_nonblock_flag(int fd) return 0; } -int container_parser_init(struct container_context *cntr, - const char *const path, unsigned int verbose) +int container_parser_init(struct container_context *cntr, int fd, + unsigned int verbose) { const struct container_parser *parsers[] = { [CONTAINER_FORMAT_RIFF_WAVE] = &container_parser_riff_wave, [CONTAINER_FORMAT_AU] = &container_parser_au, [CONTAINER_FORMAT_VOC] = &container_parser_voc, }; - int fd; const struct container_parser *parser; unsigned int size; int i; int err; assert(cntr); - assert(path); - assert(path[0] != '\0'); + assert(fd >= 0); // Detect forgotten to destruct. assert(cntr->fd == 0); @@ -167,14 +165,6 @@ int container_parser_init(struct container_context *cntr, memset(cntr, 0, sizeof(*cntr)); - // Open a target descriptor. - if (!strcmp(path, "-")) { - fd = fileno(stdin); - } else { - fd = open(path, O_RDONLY); - if (fd < 0) - return -errno; - } cntr->fd = fd; cntr->stdio = (cntr->fd == fileno(stdin)); @@ -231,9 +221,8 @@ int container_parser_init(struct container_context *cntr, return 0; } -int container_builder_init(struct container_context *cntr, - const char *const path, enum container_format format, - unsigned int verbose) +int container_builder_init(struct container_context *cntr, int fd, + enum container_format format, unsigned int verbose) { const struct container_builder *builders[] = { [CONTAINER_FORMAT_RIFF_WAVE] = &container_builder_riff_wave, @@ -241,13 +230,11 @@ int container_builder_init(struct container_context *cntr, [CONTAINER_FORMAT_VOC] = &container_builder_voc, [CONTAINER_FORMAT_RAW] = &container_builder_raw, }; - int fd; const struct container_builder *builder; int err; assert(cntr); - assert(path); - assert(path[0] != '\0'); + assert(fd >= 0); // Detect forgotten to destruct. assert(cntr->fd == 0); @@ -255,16 +242,6 @@ int container_builder_init(struct container_context *cntr, memset(cntr, 0, sizeof(*cntr)); - // Open a target descriptor. - if (path == NULL || *path == '\0') - return -EINVAL; - if (!strcmp(path, "-")) { - fd = fileno(stdout); - } else { - fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (fd < 0) - return -errno; - } cntr->fd = fd; cntr->stdio = (cntr->fd == fileno(stdout)); diff --git a/axfer/container.h b/axfer/container.h index cb64816..0840369 100644 --- a/axfer/container.h +++ b/axfer/container.h @@ -61,11 +61,10 @@ struct container_context { const char *const container_suffix_from_format(enum container_format format); enum container_format container_format_from_path(const char *path); -int container_parser_init(struct container_context *cntr, - const char *const path, unsigned int verbose); -int container_builder_init(struct container_context *cntr, - const char *const path, enum container_format format, - unsigned int verbose); +int container_parser_init(struct container_context *cntr, int fd, + unsigned int verbose); +int container_builder_init(struct container_context *cntr, int fd, + enum container_format format, unsigned int verbose); void container_context_destroy(struct container_context *cntr); int container_context_pre_process(struct container_context *cntr, snd_pcm_format_t *format, diff --git a/axfer/subcmd-transfer.c b/axfer/subcmd-transfer.c index 6962208..52c32d5 100644 --- a/axfer/subcmd-transfer.c +++ b/axfer/subcmd-transfer.c @@ -185,10 +185,19 @@ static int capture_pre_process(struct context *ctx, snd_pcm_access_t *access, *total_frame_count = 0; for (i = 0; i < ctx->cntr_count; ++i) { + const char *path = ctx->xfer.paths[i]; + int fd; uint64_t frame_count; - err = container_builder_init(ctx->cntrs + i, - ctx->xfer.paths[i], + if (!strcmp(path, "-")) { + fd = fileno(stdout); + } else { + fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (fd < 0) + return -errno; + } + + err = container_builder_init(ctx->cntrs + i, fd, ctx->xfer.cntr_format, ctx->xfer.verbose > 1); if (err < 0) @@ -226,13 +235,22 @@ static int playback_pre_process(struct context *ctx, snd_pcm_access_t *access, return err; for (i = 0; i < ctx->cntr_count; ++i) { + const char *path = ctx->xfer.paths[i]; + int fd; snd_pcm_format_t format; unsigned int channels; unsigned int rate; uint64_t frame_count; - err = container_parser_init(ctx->cntrs + i, - ctx->xfer.paths[i], + if (!strcmp(path, "-")) { + fd = fileno(stdin); + } else { + fd = open(path, O_RDONLY); + if (fd < 0) + return -errno; + } + + err = container_parser_init(ctx->cntrs + i, fd, ctx->xfer.verbose > 1); if (err < 0) return err; diff --git a/axfer/test/container-test.c b/axfer/test/container-test.c index 9b30ae3..fbef3a4 100644 --- a/axfer/test/container-test.c +++ b/axfer/test/container-test.c @@ -33,6 +33,7 @@ static void test_builder(struct container_context *cntr, void *frame_buffer, unsigned int frame_count, bool verbose) { + int fd; snd_pcm_format_t sample; unsigned int channels; unsigned int rate; @@ -41,7 +42,10 @@ static void test_builder(struct container_context *cntr, uint64_t total_frame_count; int err; - err = container_builder_init(cntr, name, format, verbose); + fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0644); + assert(fd >= 0); + + err = container_builder_init(cntr, fd, format, verbose); assert(err == 0); sample = sample_format; @@ -79,6 +83,7 @@ static void test_parser(struct container_context *cntr, void *frame_buffer, unsigned int frame_count, bool verbose) { + int fd; snd_pcm_format_t sample; unsigned int channels; unsigned int rate; @@ -86,7 +91,10 @@ static void test_parser(struct container_context *cntr, unsigned int handled_frame_count; int err; - err = container_parser_init(cntr, name, verbose); + fd = open(name, O_RDONLY); + assert(fd >= 0); + + err = container_parser_init(cntr, fd, verbose); assert(err == 0); sample = sample_format; diff --git a/axfer/test/mapper-test.c b/axfer/test/mapper-test.c index f0376c7..6252900 100644 --- a/axfer/test/mapper-test.c +++ b/axfer/test/mapper-test.c @@ -66,7 +66,6 @@ static int test_demux(struct mapper_trial *trial, snd_pcm_access_t access, unsigned int cntr_count) { struct container_context *cntrs = trial->cntrs; - char **paths = trial->paths; enum container_format cntr_format = trial->cntr_format; unsigned int bytes_per_sample; uint64_t total_frame_count; @@ -74,12 +73,17 @@ static int test_demux(struct mapper_trial *trial, snd_pcm_access_t access, int err = 0; for (i = 0; i < cntr_count; ++i) { + const char *path = trial->paths[i]; + int fd; snd_pcm_format_t format; unsigned int channels; unsigned int rate; - err = container_builder_init(cntrs + i, paths[i], cntr_format, - 0); + fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (fd < 0) + return -errno; + + err = container_builder_init(cntrs + i, fd, cntr_format, 0); if (err < 0) goto end; @@ -159,18 +163,23 @@ static int test_mux(struct mapper_trial *trial, snd_pcm_access_t access, unsigned int cntr_count) { struct container_context *cntrs = trial->cntrs; - char **paths = trial->paths; unsigned int bytes_per_sample; uint64_t total_frame_count; int i; int err = 0; for (i = 0; i < cntr_count; ++i) { + const char *path = trial->paths[i]; + int fd; snd_pcm_format_t format; unsigned int channels; unsigned int rate; - err = container_parser_init(cntrs + i, paths[i], 0); + fd = open(path, O_RDONLY); + if (fd < 0) + return -errno; + + err = container_parser_init(cntrs + i, fd, 0); if (err < 0) goto end; From patchwork Thu Mar 11 05:21:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABF02C433E0 for ; Thu, 11 Mar 2021 05:25:47 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05A4F64EB7 for ; Thu, 11 Mar 2021 05:25:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05A4F64EB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 758FD1718; Thu, 11 Mar 2021 06:24:55 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 758FD1718 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440345; bh=4NRTMp4PVgpj9g5bNAntQSSwrm11aHGAiuLS2wfgOlI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kCrfbfcOrHYB1mQXnE8wIbB2PFADQzitNSP7v3m2LraYE0/7Xad+5p03RkXRfy6By +Nj5btmvP0zYSbTdc07Cp1HgDC3lhxC0gn0e1jIZRswuVBhlFFZ29J1ismE19QEcDC EskqpP8oR1iCwccmpAflnP/SO1MsEqHj6eEUWTOk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E2DA4F804DA; Thu, 11 Mar 2021 06:22:41 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2D0B9F804B2; Thu, 11 Mar 2021 06:22:25 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D8212F80275 for ; Thu, 11 Mar 2021 06:22:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D8212F80275 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="oSpYKWJv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="f3thwc9w" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C016F1B33; Thu, 11 Mar 2021 00:21:59 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=47RuzNF0YQNme JhtRc90ZNMzmCXOdfoofVvfd7ol4GE=; b=oSpYKWJvOUc9t5ypVvIEkaLwhYZuR Mqzwuxxsqokc2g70L6oYFhOQIwbdOF5gwudVo4EhUVOBTSFgCMkhGyupZZrGSfrF Zfx91gwee3QYn2MA7nhKaUCJgIrUOzGglwb0z/2N0eHxpJ25ONfWKJHM0gd4ViDm LFQGp4BLsMC2DRs3MXq9Zf+u+RqKsuq+iZffJf8IM9rtiLwkXtBpgaOzWlz/B1jM rM3xKTfk1hrwIeLw8F8KRwdOqO28QlsWT7h/nisSu/4DSZwe+nkgykd0IStWyumQ HkzMu5NPcwuTJaLc/gGW0fz2NAJaG1fXsE3l/WZBGh/bWtjg82u55XLBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=47RuzNF0YQNmeJhtRc90ZNMzmCXOdfoofVvfd7ol4GE=; b=f3thwc9w 6KgaaZBwhwvO27ZvDF8wN1yJlo4+nyoRxp38RRWZH8waY3ZeMYC1df+4His68JxC N+WWcKUVLdoNet1cCFbemEOelp5IIChGY6Uv35/5cdB04blYo8A/SSv8j7/RchzH i6I5crCqQVfGqFRw4HzTGv2c5GvpF8/aEyq4/tzUmvx/a+/kecOC9apFh9P/4kUI ipE2POmPtYDL/VfM2VO7jxBE1DVRgDG7pMRq2E2KCeEZSmUO/L8+KXkOTXStcXNR CZ2pWbTic5zmTJmC3AyVd2EM3UmkxCGhmOPL6WTW3SQMYkjQ0vsd67nSNKY3rPI8 r8HKpaPGqBqkAw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 6621924005A; Thu, 11 Mar 2021 00:21:58 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 06/14] axfer: maintain lifetime of file descriptor outside of container module Date: Thu, 11 Mar 2021 14:21:37 +0900 Message-Id: <20210311052146.404003-7-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This commit closes file descriptor outside of container module so that maintenance of lifetime for the descriptor is delegated to container user. Signed-off-by: Takashi Sakamoto --- axfer/container.c | 1 - axfer/container.h | 1 - axfer/subcmd-transfer.c | 18 +++++++++++++-- axfer/test/container-test.c | 2 ++ axfer/test/mapper-test.c | 44 +++++++++++++++++++++++++++---------- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/axfer/container.c b/axfer/container.c index 255f12c..8c88d5c 100644 --- a/axfer/container.c +++ b/axfer/container.c @@ -451,7 +451,6 @@ void container_context_destroy(struct container_context *cntr) { assert(cntr); - close(cntr->fd); if (cntr->private_data) free(cntr->private_data); diff --git a/axfer/container.h b/axfer/container.h index 0840369..71017a6 100644 --- a/axfer/container.h +++ b/axfer/container.h @@ -11,7 +11,6 @@ #define _LARGEFILE64_SOURCE #include -#include #include #include diff --git a/axfer/subcmd-transfer.c b/axfer/subcmd-transfer.c index 52c32d5..27d2cc5 100644 --- a/axfer/subcmd-transfer.c +++ b/axfer/subcmd-transfer.c @@ -19,6 +19,8 @@ struct context { struct container_context *cntrs; unsigned int cntr_count; + int *cntr_fds; + // NOTE: To handling Unix signal. bool interrupted; int signal; @@ -153,6 +155,10 @@ static int allocate_containers(struct context *ctx, unsigned int count) return -ENOMEM; ctx->cntr_count = count; + ctx->cntr_fds = calloc(count, sizeof(*ctx->cntrs)); + if (ctx->cntr_fds == NULL) + return -ENOMEM; + return 0; } @@ -196,8 +202,9 @@ static int capture_pre_process(struct context *ctx, snd_pcm_access_t *access, if (fd < 0) return -errno; } + ctx->cntr_fds[i] = fd; - err = container_builder_init(ctx->cntrs + i, fd, + err = container_builder_init(ctx->cntrs + i, ctx->cntr_fds[i], ctx->xfer.cntr_format, ctx->xfer.verbose > 1); if (err < 0) @@ -249,8 +256,9 @@ static int playback_pre_process(struct context *ctx, snd_pcm_access_t *access, if (fd < 0) return -errno; } + ctx->cntr_fds[i] = fd; - err = container_parser_init(ctx->cntrs + i, fd, + err = container_parser_init(ctx->cntrs + i, ctx->cntr_fds[i], ctx->xfer.verbose > 1); if (err < 0) return err; @@ -447,6 +455,12 @@ static void context_post_process(struct context *ctx, free(ctx->cntrs); } + if (ctx->cntr_fds) { + for (i = 0; i < ctx->cntr_count; ++i) + close(ctx->cntr_fds[i]); + free(ctx->cntr_fds); + } + mapper_context_post_process(&ctx->mapper); mapper_context_destroy(&ctx->mapper); } diff --git a/axfer/test/container-test.c b/axfer/test/container-test.c index fbef3a4..d89852a 100644 --- a/axfer/test/container-test.c +++ b/axfer/test/container-test.c @@ -73,6 +73,7 @@ static void test_builder(struct container_context *cntr, assert(total_frame_count == frame_count); container_context_destroy(cntr); + close(fd); } static void test_parser(struct container_context *cntr, @@ -121,6 +122,7 @@ static void test_parser(struct container_context *cntr, assert(total_frame_count == handled_frame_count); container_context_destroy(cntr); + close(fd); } static int callback(struct test_generator *gen, snd_pcm_access_t access, diff --git a/axfer/test/mapper-test.c b/axfer/test/mapper-test.c index 6252900..78a063a 100644 --- a/axfer/test/mapper-test.c +++ b/axfer/test/mapper-test.c @@ -67,23 +67,29 @@ static int test_demux(struct mapper_trial *trial, snd_pcm_access_t access, { struct container_context *cntrs = trial->cntrs; enum container_format cntr_format = trial->cntr_format; + int *cntr_fds; unsigned int bytes_per_sample; uint64_t total_frame_count; int i; int err = 0; + cntr_fds = calloc(cntr_count, sizeof(*cntr_fds)); + if (cntr_fds == NULL) + return -ENOMEM; + for (i = 0; i < cntr_count; ++i) { const char *path = trial->paths[i]; - int fd; snd_pcm_format_t format; unsigned int channels; unsigned int rate; - fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (fd < 0) - return -errno; + cntr_fds[i] = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (cntr_fds[i] < 0) { + err = -errno; + goto end; + } - err = container_builder_init(cntrs + i, fd, cntr_format, 0); + err = container_builder_init(cntrs + i, cntr_fds[i], cntr_format, 0); if (err < 0) goto end; @@ -118,8 +124,12 @@ static int test_demux(struct mapper_trial *trial, snd_pcm_access_t access, assert(total_frame_count == frame_count); } end: - for (i = 0; i < cntr_count; ++i) + for (i = 0; i < cntr_count; ++i) { container_context_destroy(cntrs + i); + close(cntr_fds[i]); + } + + free(cntr_fds); return err; } @@ -163,23 +173,29 @@ static int test_mux(struct mapper_trial *trial, snd_pcm_access_t access, unsigned int cntr_count) { struct container_context *cntrs = trial->cntrs; + int *cntr_fds; unsigned int bytes_per_sample; uint64_t total_frame_count; int i; int err = 0; + cntr_fds = calloc(cntr_count, sizeof(*cntr_fds)); + if (cntr_fds == NULL) + return -ENOMEM; + for (i = 0; i < cntr_count; ++i) { const char *path = trial->paths[i]; - int fd; snd_pcm_format_t format; unsigned int channels; unsigned int rate; - fd = open(path, O_RDONLY); - if (fd < 0) - return -errno; + cntr_fds[i] = open(path, O_RDONLY); + if (cntr_fds[i] < 0) { + err = -errno; + goto end; + } - err = container_parser_init(cntrs + i, fd, 0); + err = container_parser_init(cntrs + i, cntr_fds[i], 0); if (err < 0) goto end; @@ -214,8 +230,12 @@ static int test_mux(struct mapper_trial *trial, snd_pcm_access_t access, assert(total_frame_count == frame_count); } end: - for (i = 0; i < cntr_count; ++i) + for (i = 0; i < cntr_count; ++i) { container_context_destroy(cntrs + i); + close(cntr_fds[i]); + } + + free(cntr_fds); return err; } From patchwork Thu Mar 11 05:21:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 398758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BADD6C433E0 for ; Thu, 11 Mar 2021 05:26:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F152464FC3 for ; Thu, 11 Mar 2021 05:26:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F152464FC3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 4AB441700; Thu, 11 Mar 2021 06:25:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4AB441700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440370; bh=m6bMN4ZF9dEvQvHJEteuHdraSc1UcerUQnAeIL3TIUk=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OwPCGMm/RPLIuftMIcCoXPY6Lb35AyIIllTGZuTqnRp9su3FEddj16xh3FZ49Ln/A EZun7DtQOdDZxsuDp7Aor3b21ndnG12/+A8VYdrBPtZcp+1luhnCDH71Vtjb8MTH8a TE1dHzHvOb4+UQyQTGJgAnfnyxQ9UKkvX6siEwoM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9BF7EF804DF; Thu, 11 Mar 2021 06:22:43 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9000CF804BD; Thu, 11 Mar 2021 06:22:26 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F0A13F80276 for ; Thu, 11 Mar 2021 06:22:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F0A13F80276 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="LLSdw3fX"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="v2DGwT+z" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 2EF1E2F9D; Thu, 11 Mar 2021 00:22:01 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=8rhr5NULyixo+ V2FgNFc4IgfMbSwV22Q1he19+J0e8g=; b=LLSdw3fXekYg6XGSG6iI/X4vSt5Yb 8ldTFjLBGd4mhoNDLN8l4yl9q8SfFHrL+LJ/fNYE8zjOii5b8TFEUINVdWsrQHnD A/INAyBn7Y3UusWLiEyfTXaEuwA7d+79QyB71mJnAIWhPD1PmbGPOfghNpIFsR1d U71oKUVRfz6fieNrm4Yken3pdfNlwhHWLafBlsAoB2slCQWdQPu1M4RiK2K3+D7C 0LWrEelgK8Pk4MRQQlhpfEy2znoY2H0M6zFa3rNZbrUBIKHzmbgHc5UiP0TixZxC 9P0buqmI9IM6sx2gKIw6FCTWGqPtypEre87JSWsms/RdpVOE6AGtj9HYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=8rhr5NULyixo+V2FgNFc4IgfMbSwV22Q1he19+J0e8g=; b=v2DGwT+z EedaF3mUCpN/o/IfOWZEjn6vQc41gP5S4+7TsBXngb8J+p1c4GND6EhY0RglvBo2 jfJiZEg6fk64+L0Kbvt7/Em1fXhETcETuCNNxB9mkbbmtTQj36TnuGEEizbOOnVn CGeGweE2nnGVB781NAs7IGsurNbNENk4gdPvxgaZcyk0iotiU/RTck+v8EMmP159 yhBbOZ+D7EnZtkvS6VvbmFH1VuKFv2JSCJy2R+4+E3aN6kEQQLn+yiAZm2h61PtI UYy2MvwdiPNk3ZGAfS6/3nabwplKfSSqowuLanI32OklTJyRw7FKD0MJNJ5HzEMn Vj+DtVZ04NM3kQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id B734C240057; Thu, 11 Mar 2021 00:21:59 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 07/14] autotools: preparation to use memfd_create(2) Date: Thu, 11 Mar 2021 14:21:38 +0900 Message-Id: <20210311052146.404003-8-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This is a preparation to use memfd_create(2) system call for test programs of axfer. The system call was introduced at Linux kernel v3.17 and relatively new. For safe, this commit adds detection of memfd_create() in autotools side so that application can handle the case not to detect. Signed-off-by: Takashi Sakamoto --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 7005ccc..ff3e1f6 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,11 @@ AC_CHECK_LIB([ffado], [ffado_streaming_init], [have_ffado="yes"], [have_ffado="n AS_IF([test x"$have_ffado" = xyes], [AC_DEFINE([WITH_FFADO], [1], [Define if FFADO library is available])]) +# Test programs for axfer use shm by memfd_create(2). If not supported, open(2) is used alternatively. +AC_CHECK_FUNC([memfd_create], [have_memfd_create="yes"], [have_memfd_create="no"]) +AS_IF([test x$have_memfd_create = xyes], + [AC_DEFINE([HAVE_MEMFD_CREATE], [1], [Define if Linux kernel supports memfd_create system call])]) + AM_CONDITIONAL(HAVE_PCM, test "$have_pcm" = "yes") AM_CONDITIONAL(HAVE_MIXER, test "$have_mixer" = "yes") AM_CONDITIONAL(HAVE_RAWMIDI, test "$have_rawmidi" = "yes") From patchwork Thu Mar 11 05:21:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAEBBC433E0 for ; Thu, 11 Mar 2021 05:26:30 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3905C64FC3 for ; Thu, 11 Mar 2021 05:26:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3905C64FC3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 9F5121709; Thu, 11 Mar 2021 06:25:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9F5121709 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440388; bh=Y1Z5oqqUXZx9/NOjjvKDH6O0xsoKjy673BBO7hzY4l0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DQiS08o6WMtkk4LVwDBPbkbCxQEmP+TJ8gCLRvMkwgXItkxsgHcyxRKc9cE8d/HqS KHvGK26w/W0V28foqooXkGswqG0dhwLGlSs2DPyj5zCnOzZCL4IHz0XysvYqYQA9TF OnJjsippMSzBIF5aVarHDorfixhnuWZUYgCHQCDQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C06ECF804E5; Thu, 11 Mar 2021 06:22:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F9F3F804DA; Thu, 11 Mar 2021 06:22:38 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 96685F802D2 for ; Thu, 11 Mar 2021 06:22:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 96685F802D2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="eh8zKoRk"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NBNnw3kd" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 00B3C2F95; Thu, 11 Mar 2021 00:22:02 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=KB5FiiHZGxuKj qAN6vHRFU/8JJNKlxJREV69SmH6ev4=; b=eh8zKoRkXEXnsjFv5PlXJea28CJet R5oO6R83xnlv3/UgkQocOqcZjb/ZSSEqG27xqJoj1ZZxRPwqq5jutkei4YNnLhQw w7vsvpr1PeIieoL5u9OGC3/SgKPSozejuJaVEtvnbr7xFJ9W2Dc+Vcc86Yb4+Awb DcmMjpcbW38hkFagQ1BUhAW3rLYu4iiR0aYVGTUvnUltS10+bG/HQkEPn/TOp+DF JEq3oLPa8eUKV8HjH5QTjg2zZYHza19bsGOZSpiApAKIJHs5aX9CAni8GPijt5zO /9gA95yYyk0YyuC6PaXEvGzqkqmxHpRIiJUw7BuF9BSLLHjDQfu1vv0iw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=KB5FiiHZGxuKjqAN6vHRFU/8JJNKlxJREV69SmH6ev4=; b=NBNnw3kd x229zqZ+v0A0+WJ8HJbu90zQiO3e4jEXF+V2sFYN4yNIjFGlyZgVSGODuaOXRoYR noWjK1wGyN1AzfnsOiztMGY7j/6IJjrhdIYwXtQeMpwE/9qijgxcPEpjNtI+loqe JrYSm60n/97ohSOGPkIBIotadR8RmvSR6VeiKLzdtzj559bGJ/fwqjfbvwQTb7X+ 1uQtVWKSfTDBr8LPS6jGYzbI1p76ivxG8FxfXlJKizDgLra22DXbkrDSltyo0ItP fm7PGibgDkDs0HH4tDU2AeTkSflkWWlLW9NODE7F1qguJMNeai0FxGZdV0qlZjii S3l2qleNvxcCMw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 7CB6A24005A; Thu, 11 Mar 2021 00:22:00 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 08/14] axfer: test: minor code arrangement to use the same file descriptor for container-test Date: Thu, 11 Mar 2021 14:21:39 +0900 Message-Id: <20210311052146.404003-9-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" In container test program, two file descriptors open to the same file for builder and parser contexts, however the same file descriptor is available for the case. This commit arranges to use the same file descriptor for the contexts. Signed-off-by: Takashi Sakamoto --- axfer/test/container-test.c | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/axfer/test/container-test.c b/axfer/test/container-test.c index d89852a..4d825b6 100644 --- a/axfer/test/container-test.c +++ b/axfer/test/container-test.c @@ -24,8 +24,8 @@ struct container_trial { bool verbose; }; -static void test_builder(struct container_context *cntr, - enum container_format format, const char *const name, +static void test_builder(struct container_context *cntr, int fd, + enum container_format format, snd_pcm_access_t access, snd_pcm_format_t sample_format, unsigned int samples_per_frame, @@ -33,7 +33,6 @@ static void test_builder(struct container_context *cntr, void *frame_buffer, unsigned int frame_count, bool verbose) { - int fd; snd_pcm_format_t sample; unsigned int channels; unsigned int rate; @@ -42,9 +41,6 @@ static void test_builder(struct container_context *cntr, uint64_t total_frame_count; int err; - fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0644); - assert(fd >= 0); - err = container_builder_init(cntr, fd, format, verbose); assert(err == 0); @@ -73,18 +69,16 @@ static void test_builder(struct container_context *cntr, assert(total_frame_count == frame_count); container_context_destroy(cntr); - close(fd); } -static void test_parser(struct container_context *cntr, - enum container_format format, const char *const name, +static void test_parser(struct container_context *cntr, int fd, + enum container_format format, snd_pcm_access_t access, snd_pcm_format_t sample_format, unsigned int samples_per_frame, unsigned int frames_per_second, void *frame_buffer, unsigned int frame_count, bool verbose) { - int fd; snd_pcm_format_t sample; unsigned int channels; unsigned int rate; @@ -92,9 +86,6 @@ static void test_parser(struct container_context *cntr, unsigned int handled_frame_count; int err; - fd = open(name, O_RDONLY); - assert(fd >= 0); - err = container_parser_init(cntr, fd, verbose); assert(err == 0); @@ -122,7 +113,6 @@ static void test_parser(struct container_context *cntr, assert(total_frame_count == handled_frame_count); container_context_destroy(cntr); - close(fd); } static int callback(struct test_generator *gen, snd_pcm_access_t access, @@ -156,26 +146,42 @@ static int callback(struct test_generator *gen, snd_pcm_access_t access, unlink(name); for (i = 0; i < ARRAY_SIZE(entries); ++i) { + int fd; + off64_t pos; + frames_per_second = entries[i]; - test_builder(&trial->cntr, trial->format, name, access, + fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (fd < 0) { + err = -errno; + break; + } + + test_builder(&trial->cntr, fd, trial->format, access, sample_format, samples_per_frame, frames_per_second, frame_buffer, frame_count, trial->verbose); - test_parser(&trial->cntr, trial->format, name, access, + pos = lseek64(fd, 0, SEEK_SET); + if (pos < 0) { + err = -errno; + break; + } + + test_parser(&trial->cntr, fd, trial->format, access, sample_format, samples_per_frame, frames_per_second, buf, frame_count, trial->verbose); err = memcmp(buf, frame_buffer, size); assert(err == 0); + close(fd); unlink(name); } free(buf); - return 0; + return err; } int main(int argc, const char *argv[]) From patchwork Thu Mar 11 05:21:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 398756 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D693DC433DB for ; Thu, 11 Mar 2021 05:27:34 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2503C64EB7 for ; Thu, 11 Mar 2021 05:27:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2503C64EB7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 9E4FD1704; Thu, 11 Mar 2021 06:26:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9E4FD1704 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440452; bh=TwA2R6DmbHVuJvbq36KH6uDITNZT7Ov156muPuayL+s=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iPiM9PgxaPPuVTCYXTEtvjsU3RvQ0LJU5QNy5I6WqiY39bE9XHgYCgOQCYR/bq7L0 07n4qO49rkA++69mLLZMS6jSkwBn/KeE4zNgb02GjDeexz3rPOYONZ5qM9vIY8hZyH FihGkPzDUoD+E5WkHRQcYjPKHMDSBVq0kypgMSIY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8BD62F804FC; Thu, 11 Mar 2021 06:22:57 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3F91BF804DF; Thu, 11 Mar 2021 06:22:39 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E6009F8028B for ; Thu, 11 Mar 2021 06:22:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E6009F8028B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="B8a38dNA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rKYbjXPB" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 48A612FAB; Thu, 11 Mar 2021 00:22:04 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=IOhvbMZH//nWS bbPVT69woj8xjZoDxi1XqKagcL9FCI=; b=B8a38dNAcj47HRALnFCQGPN2GSxg3 tcKv8MioUcFnKklPlC2LgayVt8dFPCpV2jFIT9LSvpIyRfjRziSu2oKFFcdMGVv6 e9mdBfjlkGG0YmxQp7JdUJWFdFlC+X7tUlyTOXnLG93sqvzu4q6Gfc6h45pdOJPn KOqTb+66FmpK64J+YrYBK44k/E/zgjk6Z/s6awhRbossFsdo5/tghFB8M99MermD CnJ4tycn/+ruVwVk5f4zcny8PfSHbduR07iaXH7Ucyzax+eT6yFdqdzIw+M1gJwN UiOSdIq/8xxCMjZwCVUHFWpj5jazPGmlsb71gqmMw0bmqmlCcxb3UHN+A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=IOhvbMZH//nWSbbPVT69woj8xjZoDxi1XqKagcL9FCI=; b=rKYbjXPB BpSz5TUHeyBUjNPJND4SJeQqwV2wjyp/6iKdJzvmNGe69414VOGp3E/JCqU0YtJq ZFxZvQl6AhK14QJfl24+Nd1QxjCYGvigUriluROViILmlSOBUm0j3rD7hZjdPNeT rzBaJVLCNhwAtVkfC2kb0YP3/FEADhbo5tlhsBZ+G6chbEeYgTz8Ka5uN/PQMn0W Q2IfTrUjNFDOq8jixncz3x1+BlV2twQt8kdCwKaPVo9fMLwAWdLoFaMpvNlKyqGk vsPq4HgBLuoEz9yQ1t6I79Md5X1HYcr29IkOMyhtgvi4B50ihGwpmDulRlv4LYX/ OdCfo1ZpHgdfQQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id D27D7240054; Thu, 11 Mar 2021 00:22:02 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 09/14] axfer: test: use memfd_create() for container-test Date: Thu, 11 Mar 2021 14:21:40 +0900 Message-Id: <20210311052146.404003-10-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" The container test program writes audio data frame to file, and read them from the file, then validate them. For the operations, usage of any in-memory file is good to shorten time of overall operations. This commit uses shm via memfd_create(). As a result, overall time to run is shorten one half of before, depending on machine environment. I note that we can achieve the same result by using O_TMPFILE flag in open(2) system call, however the implementation of O_TMPFILE is to add i-node without name on underling file system, thus it has overhead depending on implementation in each file system. On the other hand, memfd_create() is directly relevant to shm and expected to be less overhead. Signed-off-by: Takashi Sakamoto --- axfer/test/container-test.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/axfer/test/container-test.c b/axfer/test/container-test.c index 4d825b6..4e2dcc2 100644 --- a/axfer/test/container-test.c +++ b/axfer/test/container-test.c @@ -6,11 +6,20 @@ // // Licensed under the terms of the GNU General Public License, version 2. +#include +#ifdef HAVE_MEMFD_CREATE +#define _GNU_SOURCE +#endif + #include "../container.h" #include "../misc.h" #include "generator.h" +#ifdef HAVE_MEMFD_CREATE +#include +#endif + #include #include #include @@ -142,16 +151,17 @@ static int callback(struct test_generator *gen, snd_pcm_access_t access, if (buf == NULL) return -ENOMEM; - // Remove a result of a previous trial. - unlink(name); - for (i = 0; i < ARRAY_SIZE(entries); ++i) { int fd; off64_t pos; frames_per_second = entries[i]; +#ifdef HAVE_MEMFD_CREATE + fd = memfd_create(name, 0); +#else fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0644); +#endif if (fd < 0) { err = -errno; break; @@ -176,7 +186,6 @@ static int callback(struct test_generator *gen, snd_pcm_access_t access, assert(err == 0); close(fd); - unlink(name); } free(buf); From patchwork Thu Mar 11 05:21:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8200CC433E0 for ; Thu, 11 Mar 2021 05:28:07 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7833064FC3 for ; Thu, 11 Mar 2021 05:28:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7833064FC3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 BEBD51735; Thu, 11 Mar 2021 06:27:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BEBD51735 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440484; bh=WBreZIW3h8ToTg+h9dFLggAMzcpPYHl3zOwiMY+z/34=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=J5RxuiCgKIonPiHGf9BPRbXWrjA6aG0HNRwdOSRJnU9+I+xJmZyxewPwSAW/RHAxB TZRfw3V9lcYifSCWaiLGT7ODG4qlthtOUY95J0MBOWEwUbry6q8ZWNI95eZQU9/YxT xAwbRzeBHSzvH3eIR4ynF5tMjqzpKZfCz8hKhiHU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 43836F8050F; Thu, 11 Mar 2021 06:23:00 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5461BF804E0; Thu, 11 Mar 2021 06:22:38 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6D2C5F80227 for ; Thu, 11 Mar 2021 06:22:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6D2C5F80227 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="1wKnuIX6"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GGkIQraD" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id BE6652FAC; Thu, 11 Mar 2021 00:22:05 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=ppxr9iGRPYUyH iosRCnhPqwzqmvQOKxBujAlppbgIHg=; b=1wKnuIX6/ddFAU5UJCX2rzhg3SHhD o/DRiot5iiPocQIh/EUZKeIXx7mZMpkstY7QBw9xB78VxRjpPE9FF6kWqy3DK7Ay h6jCfHhoztOnm4OuTWfpaeAzkIVqcxBBRKEQofQcuGXaIoQWj9lLwbUyy9RU5O+9 hFaAJA1OuAl9xs9lWosAnPrcJiX/16v+J7yGeEqopiNZQQ8nRHoV86/2/CCEqO0w P6oqh/ltbNkRLJCvaLiITemxkuDJhmxExUnZ06xNMhqYyyKtGPp0GTYeO5gp+red 2Noynw676ZYkCDgwHwNJAKB4ZUkA+lv5EGSoWBE8NssV3iEKZD362bF4A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=ppxr9iGRPYUyHiosRCnhPqwzqmvQOKxBujAlppbgIHg=; b=GGkIQraD GI0nTqvquxKhV1+RfxGJgW9eNBpJwMnn/0KCEXnXBn00G7si4BAR4oBOBrMm+c0X Z9g0eL775eUF2Z0gqeQ6OCVM+q0siiNdLu+g+DsnK0hu3WgFLPs/0xg+we5WPPZM 0WQmK4fnE3zSZHcl5mvYrubarSzbRff1dFntErr84gcJIwlh5EmiTwQ8NWtWV8Jr 5PerXqJ1cl/3/Yx6A2mQ4Qw8/UAqfHioSg33tw7ql/SukFhEbZB7QJLQh5C3Rmpj jA0mwlfzPAvmtaWwjpJtK5dvpAyfn2tE+X0AbEL40qCG+8ominowCEc1ZYWuY+bt pN91LDEbUmmuoA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 4B21824005A; Thu, 11 Mar 2021 00:22:03 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 10/14] axfer: test: minor code arrangement to use the same file descriptor for mappter-test Date: Thu, 11 Mar 2021 14:21:41 +0900 Message-Id: <20210311052146.404003-11-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" In mapper test program, two set of file descriptors open to the same files for container builder and parser contexts, however the same file descriptor is available for the case. This commit arranges to use the same file descriptor for the contexts. Signed-off-by: Takashi Sakamoto --- axfer/test/mapper-test.c | 73 +++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/axfer/test/mapper-test.c b/axfer/test/mapper-test.c index 78a063a..0bed4bb 100644 --- a/axfer/test/mapper-test.c +++ b/axfer/test/mapper-test.c @@ -63,32 +63,20 @@ static int test_demux(struct mapper_trial *trial, snd_pcm_access_t access, unsigned int frames_per_second, unsigned int frames_per_buffer, void *frame_buffer, unsigned int frame_count, - unsigned int cntr_count) + int *cntr_fds, unsigned int cntr_count) { struct container_context *cntrs = trial->cntrs; enum container_format cntr_format = trial->cntr_format; - int *cntr_fds; unsigned int bytes_per_sample; uint64_t total_frame_count; int i; int err = 0; - cntr_fds = calloc(cntr_count, sizeof(*cntr_fds)); - if (cntr_fds == NULL) - return -ENOMEM; - for (i = 0; i < cntr_count; ++i) { - const char *path = trial->paths[i]; snd_pcm_format_t format; unsigned int channels; unsigned int rate; - cntr_fds[i] = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (cntr_fds[i] < 0) { - err = -errno; - goto end; - } - err = container_builder_init(cntrs + i, cntr_fds[i], cntr_format, 0); if (err < 0) goto end; @@ -124,12 +112,8 @@ static int test_demux(struct mapper_trial *trial, snd_pcm_access_t access, assert(total_frame_count == frame_count); } end: - for (i = 0; i < cntr_count; ++i) { + for (i = 0; i < cntr_count; ++i) container_context_destroy(cntrs + i); - close(cntr_fds[i]); - } - - free(cntr_fds); return err; } @@ -170,31 +154,19 @@ static int test_mux(struct mapper_trial *trial, snd_pcm_access_t access, unsigned int frames_per_second, unsigned int frames_per_buffer, void *frame_buffer, unsigned int frame_count, - unsigned int cntr_count) + int *cntr_fds, unsigned int cntr_count) { struct container_context *cntrs = trial->cntrs; - int *cntr_fds; unsigned int bytes_per_sample; uint64_t total_frame_count; int i; int err = 0; - cntr_fds = calloc(cntr_count, sizeof(*cntr_fds)); - if (cntr_fds == NULL) - return -ENOMEM; - for (i = 0; i < cntr_count; ++i) { - const char *path = trial->paths[i]; snd_pcm_format_t format; unsigned int channels; unsigned int rate; - cntr_fds[i] = open(path, O_RDONLY); - if (cntr_fds[i] < 0) { - err = -errno; - goto end; - } - err = container_parser_init(cntrs + i, cntr_fds[i], 0); if (err < 0) goto end; @@ -230,12 +202,8 @@ static int test_mux(struct mapper_trial *trial, snd_pcm_access_t access, assert(total_frame_count == frame_count); } end: - for (i = 0; i < cntr_count; ++i) { + for (i = 0; i < cntr_count; ++i) container_context_destroy(cntrs + i); - close(cntr_fds[i]); - } - - free(cntr_fds); return err; } @@ -247,6 +215,7 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access, void *check_buffer, unsigned int frame_count, unsigned int cntr_count) { + int *cntr_fds; unsigned int frames_per_buffer; int i; int err; @@ -254,18 +223,44 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access, // Use a buffer aligned by typical size of page frame. frames_per_buffer = ((frame_count + 4096) / 4096) * 4096; + cntr_fds = calloc(cntr_count, sizeof(*cntr_fds)); + if (cntr_fds == NULL) + return -ENOMEM; + + for (i = 0; i < cntr_count; ++i) { + const char *path = trial->paths[i]; + + cntr_fds[i] = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (cntr_fds[i] < 0) { + err = -errno; + goto end; + } + } + err = test_demux(trial, access, sample_format, samples_per_frame, frames_per_second, frames_per_buffer, frame_buffer, - frame_count, cntr_count); + frame_count, cntr_fds, cntr_count); if (err < 0) goto end; + for (i = 0; i < cntr_count; ++i) { + off64_t pos = lseek64(cntr_fds[i], 0, SEEK_SET); + if (pos != 0) { + err = -EIO; + goto end; + } + } + err = test_mux(trial, access, sample_format, samples_per_frame, frames_per_second, frames_per_buffer, check_buffer, - frame_count, cntr_count); + frame_count, cntr_fds, cntr_count); end: - for (i = 0; i < cntr_count; ++i) + for (i = 0; i < cntr_count; ++i) { unlink(trial->paths[i]); + close(cntr_fds[i]); + } + + free(cntr_fds); return err; } From patchwork Thu Mar 11 05:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 398757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 201AFC433E0 for ; Thu, 11 Mar 2021 05:26:52 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5C4B264FC9 for ; Thu, 11 Mar 2021 05:26:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C4B264FC9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 E44C21720; Thu, 11 Mar 2021 06:25:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E44C21720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440410; bh=hWsnkRuJb7qpnixsMMtNyG+ABHy4L4oG0RnnCp0JdV0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=K30Qk78BgYe1g2OQIdXrQ3UaBs4fGJuGHAEXn10qahouoMFYz3oJaqCaz7gWqYeXa 9MXxE2xzLjC1vQ3H9pQunytI6telQovXMvYCtVUgBhvfuVbg8X6sumdKXIP2qCVe8Q PXLmiOcYz4Gf9Fv0Xyz6Sk7UiMG7CELwAOaDar2c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 724DEF8019B; Thu, 11 Mar 2021 06:22:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E1489F80227; Thu, 11 Mar 2021 06:22:38 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AE90EF8032C for ; Thu, 11 Mar 2021 06:22:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AE90EF8032C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="lm/tEIq1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="eFiCcbBD" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 1AA112FA0; Thu, 11 Mar 2021 00:22:07 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=c8CvjuUr3RQk5 H387/Mvm7ZDVN3RPJbq9mHJK9/9FPE=; b=lm/tEIq10m/0hmYV394BUwklNeJk0 ssfMi04Js0eOEBWHNFb+W0KBnL9rgZh2/+vT2OlMtb3sIn6TyONE7zeYTTdsabHF iKdLe9FP/OGLUDoA3bD2xW5366vq7H/2dbO5QYQGplxmlqiVQ5Jq3TfumDoxWtGC UlDJrPPPASFFfGaK4i/ZEI8qJsScxSfjyu7CUIqqm2jpi9fOajC6Fxh+8HJjYJKz TVtZ5TBXatVXYy9CiFTBfZIKBUOd9IoclGjLEcR7rMQiPyoQnlqGScjFY4+mkVY2 iBHNLD34VVitmlAiVrGsGjSOROGUTmc7+x7OJm5NbCTfW7CkKKZ60f7jA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=c8CvjuUr3RQk5H387/Mvm7ZDVN3RPJbq9mHJK9/9FPE=; b=eFiCcbBD vDw5kqFgh7Jm2uFLmuBES9l8WnXTjDCoaKvbmqGUTruyuP3MWk7m504WKyQCF+dE yrI5K34PayTyQ75yyMZSjnjE0aRy+bLjrAjrezkOlIYWBDctBi56nnTJdREoSjyP FM7NmI1D22iOolB4VqkFnm5IPmXJVPeAfQR41yHq3yjUd7iijqK494wv5kzslnSf aZXJXkKAx6/6+/Jp8YS9wvf33I+UIAO0k0bmKuMlwdFUlThEhvRs4euqLS9bXjYZ Jv1wnQVG41fQyDp9Afs+/KxBZF5/ZvmR3DjLZEoV5CB/gTcDDVe0YHfrE4lmjMGO 6mHUwVKRmhStlQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id A6080240054; Thu, 11 Mar 2021 00:22:05 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 11/14] axfer: test: use memfd_create() for mapper-test Date: Thu, 11 Mar 2021 14:21:42 +0900 Message-Id: <20210311052146.404003-12-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" The mapper test program writes audio data frame to files, and read them from the files, then validate them. For the operations, usage of any in-memory file is good to shorten time of overall operations. This commit uses shm by memfd_create(). Signed-off-by: Takashi Sakamoto --- axfer/test/mapper-test.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/axfer/test/mapper-test.c b/axfer/test/mapper-test.c index 0bed4bb..477871d 100644 --- a/axfer/test/mapper-test.c +++ b/axfer/test/mapper-test.c @@ -6,11 +6,20 @@ // // Licensed under the terms of the GNU General Public License, version 2. +#include +#ifdef HAVE_MEMFD_CREATE +#define _GNU_SOURCE +#endif + #include "../mapper.h" #include "../misc.h" #include "generator.h" +#ifdef HAVE_MEMFD_CREATE +#include +#endif + #include #include #include @@ -230,7 +239,11 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access, for (i = 0; i < cntr_count; ++i) { const char *path = trial->paths[i]; +#ifdef HAVE_MEMFD_CREATE + cntr_fds[i] = memfd_create(path, 0); +#else cntr_fds[i] = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644); +#endif if (cntr_fds[i] < 0) { err = -errno; goto end; @@ -255,10 +268,8 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access, frames_per_second, frames_per_buffer, check_buffer, frame_count, cntr_fds, cntr_count); end: - for (i = 0; i < cntr_count; ++i) { - unlink(trial->paths[i]); + for (i = 0; i < cntr_count; ++i) close(cntr_fds[i]); - } free(cntr_fds); From patchwork Thu Mar 11 05:21:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FC1EC433DB for ; Thu, 11 Mar 2021 05:27:12 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42FAB64FC9 for ; Thu, 11 Mar 2021 05:27:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42FAB64FC9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 A199C1703; Thu, 11 Mar 2021 06:26:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A199C1703 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440429; bh=/w4VIcxS8vrH/sSZvqN9w6UZmSo6kozRlXSNQzzU+CE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tTlokddvljsuiTosK/Rm5kdbTePVCGfHswt17LEpX9AvqAlbenCi+KMHKlUdFtgAR M6FZ0xYSTDRv2YS03p9JeC5lo2nVvDtSeRaQvPZd0/BSP7Sm+1NkVm2oHIrC7pzEnC x+0Ud2nqdaqL8EYcnAMWZn+aooDF8HUz0YA27vkc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6A160F804F2; Thu, 11 Mar 2021 06:22:56 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EDD1CF8032B; Thu, 11 Mar 2021 06:22:38 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 115D9F8032B for ; Thu, 11 Mar 2021 06:22:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 115D9F8032B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="kUGb0xSD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IW2k6GJt" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 61A782F88; Thu, 11 Mar 2021 00:22:08 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=J9guudtb6Eogk 0WZpXeQnCskSuocbkmRpzRjcLI3Lik=; b=kUGb0xSDsDAvFejFzREd1yiltyLhU UEtwSAUeXUHce0dkVpLQ+xLJo6EoI+h5c2FAZuf8P5tGVUcdL1YWQ8QNt2HeMGa1 6VC+5M2fE+IKqKVFdpPj+WV+bleOrZ8e/w6/DjkSxeBXrg5DBpJStQOoGQFp6AgO HnpdupZMQuGupXNXDgnbuYoeRXeGo8lYl8ugcqxherZKK0vAa0QE4UHX6DSCcymZ t1sB4xcKVuPAlBu9HypuQ5r5SYsSaxLPW47eUqm740yD0OSexceO0cbibzcJpG8C V5YorGCB3xnICpXZK+12Fg26xZgMBw48g/zUuENhCZOx3LUCij7+lQd5w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=J9guudtb6Eogk0WZpXeQnCskSuocbkmRpzRjcLI3Lik=; b=IW2k6GJt M+JyUT5KA9vUYhIjPLI93tpMjgh7qBn9dmzMvHiNCNBesWNCUWXQRWwewBM+/E0k mFKEwUwsN3EjRHv3phsBCYBAtZVqHcPimPtsz4kMapXyAniJq7NLhq/g6OyQTqYN tHUCVI/WnywhYnvAenIHVIldvOnAuWCoDStwgWDIeh6pUweoeztW3pWXs0URM007 xzRE4ooWf6tLTIN5amaSqHgRO1QoFXPXun7TODDrh+XdoBIksCWj/BpRXYkVZwh9 mrAPWccEamk3Cgm/lCcYu7y8SijBX1ql2zyjEquV7hAo9SGy48sQA7je+amhX/ZE 2BTP+IPFLEwKHw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id F3CB5240057; Thu, 11 Mar 2021 00:22:06 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 12/14] axfer: test: reduce test case for maximum number of frame count Date: Thu, 11 Mar 2021 14:21:43 +0900 Message-Id: <20210311052146.404003-13-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This commit reduces test case for maximum number of frame count so that overall time is shortened. The count of total iteration is still the same. Signed-off-by: Takashi Sakamoto --- axfer/test/container-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/axfer/test/container-test.c b/axfer/test/container-test.c index 4e2dcc2..788507b 100644 --- a/axfer/test/container-test.c +++ b/axfer/test/container-test.c @@ -300,7 +300,7 @@ int main(int argc, const char *argv[]) for (i = begin; i < end; ++i) { err = generator_context_init(&gen, access_mask, sample_format_masks[i], - 1, 128, 23, 4500, 1024, + 1, 128, 23, 3000, 512, sizeof(struct container_trial)); if (err >= 0) { trial = gen.private_data; From patchwork Thu Mar 11 05:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 398754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E024C433DB for ; Thu, 11 Mar 2021 05:29:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80D3264FC4 for ; Thu, 11 Mar 2021 05:29:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 80D3264FC4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 E006A172C; Thu, 11 Mar 2021 06:28:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E006A172C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440546; bh=4gGhQEflyU+oi6w1WzQ9TAOysKzm/K4E0EaBNTugjB4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DD3Is5Vq5oKxV3Vv+C7nijJEEthrpWNobh1UajYL0WfpfkOlOGXUz9e6lazDQu9SB uB4FvnFTi9C0YaYKN9k73Oo35+fmtAh+Ewqgzp3GFTB6DOn4d+wxJDGYJG6idr1Qjo XSXhPgTyKIjXAIVVaogOWQ+XRBj1Nmr7OqlshO7c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2CE10F8051D; Thu, 11 Mar 2021 06:23:04 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 67FCFF804ED; Thu, 11 Mar 2021 06:22:49 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 76C87F8019B for ; Thu, 11 Mar 2021 06:22:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 76C87F8019B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="udS8/Wfb"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nGeEUDSp" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id C71F12FB1; Thu, 11 Mar 2021 00:22:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=VFcSEjkdAFaQv Dbt65kFzXcJZaVcyUHzaDAHX7DHzJ8=; b=udS8/WfbH0qGRJrf6z66osxi5WQ54 9lOmmgy24xwjwCPdpUQzm2tXrDQRt5rvmmbw9hPFROFGIclgtzO/4fNCsyH0SbRV kNFfwwYEjUqmYaWBRrBcbXqTJf0F3MNcprWtyXK4hOybveQKDCS88E8LTr6XPrX8 kAaRxs2DjttnEgezCEb4ZysK9Ie0Du9GIT+z+25y1T1OksjeFH9E4HDqqLo2xiDI e3AOaur85RYe5vs8TzCGbVuwTCCi0JUqrRNtspTIcuSAF49L0JQvVX6Y1WW5m4cf rkwdKJw6+KejSeO/YwggqithWyvTIzWF0OURi5QjBKO9s4vCsQOo61L5Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=VFcSEjkdAFaQvDbt65kFzXcJZaVcyUHzaDAHX7DHzJ8=; b=nGeEUDSp rO3ry/dyqUHT8hNAl/Ei4cbLUPstR05oLjQNRCeQV14PuikbtYUN1DwZxYTA4Smi 2FDupI9shOtt6lWQoMyo5T7IYifBOpuA7eqYKuH0hNh4Px11egnKnKcGpiXKDn9K WnlnbtsNjti4U4yVCkP/gkEpiNw47Mi59vFsAggkoKPSpyG59qdCAErJ2xgVxZuc IrqCt++C52aZEMFaq7NlJzvdZ3i5qYtE7DYaVxTQg3ctIACR6Lk/GLDgPNEqNSZW Yu5fqDL9TXDWaYwtTHz0Ldvp/XcT7fYGXQ9O86IhL1R7V0pgrahNtHwOaf/gdXgL Etdk7YytZrNZlA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 6653E240054; Thu, 11 Mar 2021 00:22:08 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 13/13] Revert "axfer: test - add run-test-in-tmpdir.sh script" Date: Thu, 11 Mar 2021 14:21:44 +0900 Message-Id: <20210311052146.404003-14-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This reverts commit e1551de8dd28c3a63f8d7c146952a8d2649ac9de since tests run for in-memory files now. Signed-off-by: Takashi Sakamoto --- axfer/test/run-test-in-tmpdir.sh | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100755 axfer/test/run-test-in-tmpdir.sh diff --git a/axfer/test/run-test-in-tmpdir.sh b/axfer/test/run-test-in-tmpdir.sh deleted file mode 100755 index e66fa73..0000000 --- a/axfer/test/run-test-in-tmpdir.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -bin="$1" - -test -z ${bin} && exit 90 -test ! -x ${bin} && exit 91 -test -z ${TMPDIR} && exit 92 -test ! -d ${TMPDIR} && exit 93 - -tmp_dir=$(mktemp -d ${TMPDIR}/container-test.XXXXX) -cur_dir=$(pwd) - -echo ${tmp_dir} -cd ${tmp_dir} -${cur_dir}/${bin} -retval=$? -cd ${cur_dir} -rm -rf ${tmp_dir} -exit $retval From patchwork Thu Mar 11 05:21:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 397593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AB0CC433E0 for ; Thu, 11 Mar 2021 05:28:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A4D8564FC9 for ; Thu, 11 Mar 2021 05:28:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4D8564FC9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 19BAB172B; Thu, 11 Mar 2021 06:27:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 19BAB172B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615440528; bh=4gGhQEflyU+oi6w1WzQ9TAOysKzm/K4E0EaBNTugjB4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tDmxZMJ0Ov7Lu53wlgFcUkenSv9QezBS2ixDB58NkkeXmPZ746GCxhVhNWTzeO6ZV kWW72NIgLACciQVKLkpFqI7l9TgKTPu0M1bZnVf/rxdkHTtRhAaQNS9FV/Iy63j7GC gOrKGYX0ntVkrXgCTuW3gpCVwjhLk/GB9WOg2Hwo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 68502F8051B; Thu, 11 Mar 2021 06:23:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 54EBFF804EB; Thu, 11 Mar 2021 06:22:48 +0100 (CET) Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2503EF80431 for ; Thu, 11 Mar 2021 06:22:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2503EF80431 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="WL75j8EL"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="pss/YvT0" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 7F3A82FCB; Thu, 11 Mar 2021 00:22:12 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 11 Mar 2021 00:22:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=VFcSEjkdAFaQv Dbt65kFzXcJZaVcyUHzaDAHX7DHzJ8=; b=WL75j8ELdFczgNGzAGm3+5cDodl01 ju0RbacdjroHTKNQzy0uEQLtKqDq+YlsUSLnWaFZ5Hoy7T+Qbw/JmnBbwOSGt2yZ ne6/W7MvaoNSW6cphDdBFOgI1VrkueKySltNySs4l9xr9OY621SKWENW0NqJOnKH 9UjOv5BMbDZlrLmeHX9UybBd+wOhM/3HDM3Z9qw7pSmXPxyIOQbFcRazSygQUArg UGYQ2oezTONNSMXY1sJMWht1QEBlXdjTvZVcj9Hui2xtdUerjp4iSSOlXVHHkACP dNyJbM0nYKNr6d14slAqUBecCqFIEX5YRRIzJ4WXHBovbUNiw1RHKn8Bg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=VFcSEjkdAFaQvDbt65kFzXcJZaVcyUHzaDAHX7DHzJ8=; b=pss/YvT0 gdyjsRoSzN+qFeVoZJ+Lni4eNhjlsXcl3f471M8xkQ5qmdxS+dB16OLy6pUVBftI bOp7vxCKBTvr4srTVv3rgueXYtVqhVN6QBqpW3xZoLFor1IRGubz904khLawVvsb EkBajDxl6f0EPSpEpJ8RbWC9fU6D96L1JAFN0+rAbuqJYLjc1oNGAfSH3GDf0O89 nqQCw1Zqdu4NB9EJtVeN94OfewHcq2XY7wxZFDWuSRY5dxQotY+ZXBmdJ6kmmEnS d7piqgB+Men2AsLT+OWnrIvwGfmiri4ln6+E/iyJMWlBwwLAGHj3jPDgnCYoL/87 olcJocT/rAZd1A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudduledgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecukfhppedugedr fedrieehrddujeehnecuvehluhhsthgvrhfuihiivgepkeenucfrrghrrghmpehmrghilh hfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: from workstation.flets-east.jp (ae065175.dynamic.ppp.asahi-net.or.jp [14.3.65.175]) by mail.messagingengine.com (Postfix) with ESMTPA id 13AA7240054; Thu, 11 Mar 2021 00:22:10 -0500 (EST) From: Takashi Sakamoto To: tiwai@suse.de, perex@perex.cz Subject: [alsa-utils][PATCH 14/14] Revert "axfer: test - add run-test-in-tmpdir.sh script" Date: Thu, 11 Mar 2021 14:21:46 +0900 Message-Id: <20210311052146.404003-16-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210311052146.404003-1-o-takashi@sakamocchi.jp> References: <20210311052146.404003-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org 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" This reverts commit e1551de8dd28c3a63f8d7c146952a8d2649ac9de since tests run for in-memory files now. Signed-off-by: Takashi Sakamoto --- axfer/test/run-test-in-tmpdir.sh | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100755 axfer/test/run-test-in-tmpdir.sh diff --git a/axfer/test/run-test-in-tmpdir.sh b/axfer/test/run-test-in-tmpdir.sh deleted file mode 100755 index e66fa73..0000000 --- a/axfer/test/run-test-in-tmpdir.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -bin="$1" - -test -z ${bin} && exit 90 -test ! -x ${bin} && exit 91 -test -z ${TMPDIR} && exit 92 -test ! -d ${TMPDIR} && exit 93 - -tmp_dir=$(mktemp -d ${TMPDIR}/container-test.XXXXX) -cur_dir=$(pwd) - -echo ${tmp_dir} -cd ${tmp_dir} -${cur_dir}/${bin} -retval=$? -cd ${cur_dir} -rm -rf ${tmp_dir} -exit $retval