From patchwork Mon Nov 5 14:23:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 10668337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7F2314BD for ; Mon, 5 Nov 2018 14:23:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A39FE28FEA for ; Mon, 5 Nov 2018 14:23:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94CE62933C; Mon, 5 Nov 2018 14:23:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14E2A28FEA for ; Mon, 5 Nov 2018 14:23:37 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0355E2678DD; Mon, 5 Nov 2018 15:23:36 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5CA692678F7; Mon, 5 Nov 2018 15:23:33 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60044.outbound.protection.outlook.com [40.107.6.44]) by alsa0.perex.cz (Postfix) with ESMTP id 2D0F42678DA for ; Mon, 5 Nov 2018 15:23:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rxMJVB0r+D6PjwiSrQWFOcLf0m39ADgyDleIcjieFXY=; b=PfKqtVzLtZyzMNl9X+FZ/QkiU7Ot0nIInIFbuXVZt54ED30dBbYOPKLCMBGlwLgDAjdYkpyLKJBvRDS46B1rpagXJQWh3Si8auYCZIXw94KYNrnezRSfG7aVqD74lhrEGqlcqsKO6Np/u4SV28IpkIEc7QaRK0yeWs+VQPEKQkw= Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com (52.134.1.18) by VI1PR0402MB3888.eurprd04.prod.outlook.com (52.134.17.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.26; Mon, 5 Nov 2018 14:23:27 +0000 Received: from VI1PR0402MB3357.eurprd04.prod.outlook.com ([fe80::1508:3b1f:85e3:745c]) by VI1PR0402MB3357.eurprd04.prod.outlook.com ([fe80::1508:3b1f:85e3:745c%3]) with mapi id 15.20.1294.032; Mon, 5 Nov 2018 14:23:27 +0000 From: Daniel Baluta To: "alsa-devel@alsa-project.org" Thread-Topic: [RFC PATCH] cplay: Always write frag * fragment_size Thread-Index: AQHUdRMe1DlWlHA6Vka7OPc68YCpyQ== Date: Mon, 5 Nov 2018 14:23:27 +0000 Message-ID: <1541427790-27876-1-git-send-email-daniel.baluta@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5PR0502CA0007.eurprd05.prod.outlook.com (2603:10a6:203:91::17) To VI1PR0402MB3357.eurprd04.prod.outlook.com (2603:10a6:803:2::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=daniel.baluta@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [95.76.156.53] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR0402MB3888; 6:QxG4hsW1EFRmuyL9e/sj82NL4h0qLG5JAu9SPtJ3u10BU/cAw9+t82na0m3Kk7UkOJeF85mnwnhxO8/ZA9pn/vuXMTqX7UPWgVJeGxvZ1C7fJtmTH9QwdwUXWBEitQfNi83dig6xenpv4NjpAYQb5cDKy7a6dQ22N1gRHpsmHKlWLND/+tj2TDSe+J8CgP0Heh/b8KmxMuBHGJrcIeUz65227pPIMsERug1UCZDa38etXxgviL4QQQIrAQCcnw1o6acSoKlbQ+gXfT/XsTRhyEDnuGf2Vw9MTzIxzdPmGnSnYiB4p0yczghDXO6/1B8qoc9SLXaxmkNhFInB5AOTotm30lvfkLUurxfj+QVm5zjo5jVzQguRAtZ0ULda1yQqAsYRf/UQrgbicNRFWVXpc2aEQEKV+I20kN8BM5IsNYymytIyioNxZ5vMTjWoUwrDnsuddEIYxMnPmvMM27lSNg==; 5:NUFi37imx/HPwC8MVfmKTyzfhG1MuInwVgrQYKXxSyqfU+0bbVo2jK26oHkpVpHm90kUG7qMSoGh78dTMhYv8iJwKbp4L+Dwjc3eB3pGayIJnunt9yrO701rVgFHGaikQTHL/RNy/IevlgHW8Zdcdu0YNm1CcZg8eOZWzszNprM=; 7:5zqFZHQaMSvaC7v3eKx73ht2uB4fvnUycOHTPHnBlBR/9VNP4rpkiU7UzyKq4iAE+F9tt9BzqxhnRYn0gC67jo0nmudRmADL0v7v6Kcu9+TpGkj9aEnd1hEQPFF5Eob6U91/SWFnf3WAD555AJ/D5Q== x-ms-office365-filtering-correlation-id: 04371549-f6a0-481e-6c46-08d6432a4073 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3888; x-ms-traffictypediagnostic: VI1PR0402MB3888: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(185117386973197); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231382)(944501410)(52105095)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:VI1PR0402MB3888; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3888; x-forefront-prvs: 08476BC6EF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(366004)(346002)(376002)(39860400002)(396003)(189003)(199004)(8936002)(4326008)(44832011)(305945005)(25786009)(99286004)(5660300001)(6916009)(6486002)(86362001)(97736004)(6116002)(316002)(3846002)(7736002)(105586002)(5640700003)(6436002)(54906003)(2616005)(476003)(486006)(256004)(52116002)(81156014)(81166006)(2351001)(106356001)(2900100001)(6512007)(53936002)(71200400001)(478600001)(71190400001)(186003)(26005)(2906002)(36756003)(66066001)(2501003)(68736007)(386003)(6506007)(8676002)(102836004)(14454004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3888; H:VI1PR0402MB3357.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Wa44vIH4cM5o076u86l6amp4mk8hbNs+z3EAMaycGQkK5Q8aDLGsneFqVCMVgqTXOmvTYczp0u1pKKI5F7femnUgjS+mK1bixNY9qb0zqp5DPCjB+dTb535wlN2wXID4fkR8La2Sqng1xvcspghuNAANocJO7+1n9ehwXxdcbnrlHy5vQkieC5GbdxOrDZe30exgWABNBDEtKOUnwer9W8wX74DGEzYhbdvU2v0YgNL7qyrOK793SjD24GsE2IPCI9X9oVX8siKCjR9ywojZzOpSBjL+eUkSkuzi7JyaIv176Y5rp62UXuNcFK8tn+SzQLC/UwrTac8mzGTWAaIWJGp2yym2AW9FfeijjxsZ7qc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04371549-f6a0-481e-6c46-08d6432a4073 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Nov 2018 14:23:27.3497 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3888 Cc: "S.j. Wang" , "vinod.koul@linux.intel.com" , Daniel Baluta , "vkoul@kernel.org" Subject: [alsa-devel] [RFC PATCH] cplay: Always write frag * fragment_size X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP cplay first writes frag * fragment_size and then it only writes one fragment at a time. This means for example than if the user supplied a buffer_size it will only be used for the first write. Signed-off-by: Daniel Baluta Reviewed-by: Charles Keepax --- I noticed this while investigating why cplay prints buffer_size as 0 when not specified as command line argument to cplay. I also noticed that cred always reads frag * frament_size, so I think this patch should be OK, but marking it as RFC to get your thoughts. src/utils/cplay.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/cplay.c b/src/utils/cplay.c index 2a52b52..b016f52 100644 --- a/src/utils/cplay.c +++ b/src/utils/cplay.c @@ -435,15 +435,15 @@ void play_samples(char *name, unsigned int card, unsigned int device, }; if (verbose) printf("%s: Opened compress device\n", __func__); - size = config.fragment_size; - buffer = malloc(size * config.fragments); + size = config.fragments * config.fragment_size; + buffer = malloc(size); if (!buffer) { fprintf(stderr, "Unable to allocate %d bytes\n", size); goto COMP_EXIT; } /* we will write frag fragment_size and then start */ - num_read = fread(buffer, 1, size * config.fragments, file); + num_read = fread(buffer, 1, size, file); if (num_read > 0) { if (verbose) printf("%s: Doing first buffer write of %d\n", __func__, num_read); @@ -459,7 +459,7 @@ void play_samples(char *name, unsigned int card, unsigned int device, } } printf("Playing file %s On Card %u device %u, with buffer of %lu bytes\n", - name, card, device, buffer_size); + name, card, device, size); printf("Format %u Channels %u, %u Hz, Bit Rate %d\n", codec.id, codec.ch_in, codec.sample_rate, codec.bit_rate);