From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 83288C43334 for ; Thu, 16 Jun 2022 08:14:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F142F1A3B; Thu, 16 Jun 2022 10:14:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F142F1A3B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1655367291; bh=dy+gdn0Xi92bMgexTrlBXZEETPRxHoxDU7522ojrfjk=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qLRA8C1HXQkRuxutPoVQd9PM/DD+rLTOu0ApSSJ7TgFatVnsA1ylxbG1qCv3gryO7 pyQTmadBwE2D/G1aPlqpoaet5fdB8ESOW07m8DYNBcK6rq5Y2sby1SvjZ4jIcbKIHV S/CaOOKU5/xlhEx/ttesCdmCBI6mx84/oziEUrPQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7E60BF800B9; Thu, 16 Jun 2022 10:14:00 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5C30DF801D8; Thu, 16 Jun 2022 10:13:59 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AF392F800B9 for ; Thu, 16 Jun 2022 10:13:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AF392F800B9 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="wqb40OpR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="C327SzpF" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id C58695C082B; Thu, 16 Jun 2022 04:13:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 16 Jun 2022 04:13:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1655367225; x=1655453625; bh=mV JEolc0OFYoYuhw+AP5Anf6kn9xhkygOSKD5uAd+7w=; b=wqb40OpRLyuFSVXwtu RLK0qLhHihhBHDRjN34U7wpfOp+tY/Dy6pD0saaXbb9SQVkockqAx+LeiPTrz2PU Bzoi52kG7X2gpKoRNUWJ9z1imm2jzhucw3bvccMNTocV25OMxqhWRkQUCnJ78Is7 YrASi4g64lC588vREKYFM+u+JMHp2pXAynOf1t2OU2k6CQ3NLg40DYtvLUzE5H3W qJzvX+EzRG+bwdRtVm5kifk7G8bPn9PRrpYAUV+WWj1xR9KZxltH4WVTID8MMAIy H00kU4z5bJ8YRFmkbFjfcDXHoGN2xJybWOeG/eNxLr/xBErHyFRONnFlXpgGMi0N udug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1655367225; x=1655453625; bh=mVJEolc0OFYoYuhw+AP5Anf6kn9x hkygOSKD5uAd+7w=; b=C327SzpFXzfbupJ0KH4hcOAw1N53JpZibxWQfQSAOVB4 sgPkydFqu0qbSV1pAglQCLil+6CY7qFEwv1e0Dpj31egVO1FG8jv9MWIRglRl6BR qw8F4ED+PjlUcIkJOdPtUoli5qwhFRERFIPqPICFyvxeVm3bngfxVMiSYZNaI+4I 3vJizhu/mFSlX0zv1UmixHF9YIzxQqdWt7zL19oMdxFrFthksFbuSCdClO+MDEuw QAI1aycbacuDhUJiwPJwsaRL/WQ3aB+LOABYm9hQM7v6eyH9QrtyhsAPpAkvr1ni jGryR3xD1gBAsvYorNrDa8DkMubtqRx/bxXofta8yQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvvddguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvrghk rghshhhiucfurghkrghmohhtohcuoehoqdhtrghkrghshhhisehsrghkrghmohgttghhih drjhhpqeenucggtffrrghtthgvrhhnpeehhffhteetgfekvdeiueffveevueeftdelhfej ieeitedvleeftdfgfeeuudekueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjhhp X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 16 Jun 2022 04:13:43 -0400 (EDT) Date: Thu, 16 Jun 2022 17:13:41 +0900 From: Takashi Sakamoto To: Pavel Hofman Subject: Re: [PATCH] aplay: Support setting timestamp Message-ID: Mail-Followup-To: Pavel Hofman , alsa-devel@alsa-project.org References: <20220616065426.27915-1-pavel.hofman@ivitera.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220616065426.27915-1-pavel.hofman@ivitera.com> 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" Hi, On Thu, Jun 16, 2022 at 08:54:26AM +0200, Pavel Hofman wrote: > To allow enabling timestamp and specify its type, a new option > --tstamp-type=TYPE is added. Recognized values are none (default), > gettimeofday, monotonic, monotonic-raw. > > Signed-off-by: Pavel Hofman > --- > aplay/aplay.1 | 4 ++++ > aplay/aplay.c | 32 ++++++++++++++++++++++++++++++++ > 2 files changed, 36 insertions(+) I prefer the idea to work for timestamp feature defined in ALSA PCM interface, while I have a mixed feeling to integrate `aplay` tool, since I have an intension to obsolete the tool with `axfer` tool with more robust design with command argument compatibility (as much as possible). This is not so strong request but would I ask you to work for `axfer` tool instead of `aplay`? Then, it's preferable that the name of command argument is decided with enough care of all of timestamp feature in ALSA PCM interface, since we have two categories of timestamps at least; e.g. system timestamp and audio timestamp. As long as I know, they possibly use different clock sources, thus these two timestamps have different levels of clock id, I think. Of course, it's a loose accord in the community to obsolete `aplay`, and it's easy to decide to continue aplay integration. (I'm not in leading place of the project.) I'll be a bit happy if people take care of axfer tool as well. Regards Takashi Sakamoto > diff --git a/aplay/aplay.1 b/aplay/aplay.1 > index 3bba59d..d3b7dce 100644 > --- a/aplay/aplay.1 > +++ b/aplay/aplay.1 > @@ -207,6 +207,10 @@ sampling rates, numbers of channels, period and buffer bytes/sizes/times. > For raw device hw:X this option basically lists hardware capabilities of > the soundcard. > .TP > +\fI\-\-tstamp\-type=TYPE\fP > +Specifies timestamp type inside the software configuration container. > +Types are: none (default), gettimeofday, monotonic, monotonic\-raw. > +.TP > \fI\-\-fatal\-errors\fP > Disables recovery attempts when errors (e.g. xrun) are encountered; the > aplay process instead aborts immediately. > diff --git a/aplay/aplay.c b/aplay/aplay.c > index 63a4e34..5d15a32 100644 > --- a/aplay/aplay.c > +++ b/aplay/aplay.c > @@ -139,6 +139,8 @@ static int use_strftime = 0; > volatile static int recycle_capture_file = 0; > static long term_c_lflag = -1; > static int dump_hw_params = 0; > +static int enable_tstamp = 0; > +static snd_pcm_tstamp_type_t tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY; > > static int fd = -1; > static off64_t pbrec_count = LLONG_MAX, fdcount; > @@ -244,6 +246,8 @@ _("Usage: %s [OPTION]... [FILE]...\n" > " --process-id-file write the process ID here\n" > " --use-strftime apply the strftime facility to the output file name\n" > " --dump-hw-params dump hw_params of the device\n" > +" --tstamp-type=TYPE set timestamp (TYPE: none (default), gettimeofday,\n" > +" monotonic, monotonic-raw)\n" > " --fatal-errors treat all errors as fatal\n" > ) > , command); > @@ -430,6 +434,7 @@ enum { > OPT_PROCESS_ID_FILE, > OPT_USE_STRFTIME, > OPT_DUMP_HWPARAMS, > + OPT_TSTAMP_TYPE, > OPT_FATAL_ERRORS, > }; > > @@ -517,6 +522,7 @@ int main(int argc, char *argv[]) > {"use-strftime", 0, 0, OPT_USE_STRFTIME}, > {"interactive", 0, 0, 'i'}, > {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, > + {"tstamp-type", 1, 0, OPT_TSTAMP_TYPE}, > {"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, > #ifdef CONFIG_SUPPORT_CHMAP > {"chmap", 1, 0, 'm'}, > @@ -799,6 +805,23 @@ int main(int argc, char *argv[]) > case OPT_DUMP_HWPARAMS: > dump_hw_params = 1; > break; > + case OPT_TSTAMP_TYPE: > + if (strcasecmp(optarg, "gettimeofday") == 0) { > + enable_tstamp = 1; > + tstamp_type = SND_PCM_TSTAMP_TYPE_GETTIMEOFDAY; > + } else if (strcasecmp(optarg, "monotonic") == 0) { > + enable_tstamp = 1; > + tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC; > + } else if (strcasecmp(optarg, "monotonic-raw") == 0) { > + enable_tstamp = 1; > + tstamp_type = SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW; > + } else if (strcasecmp(optarg, "none") == 0) > + enable_tstamp = 0; > + else { > + error(_("unrecognized timestamp type %s"), optarg); > + return 1; > + } > + break; > case OPT_FATAL_ERRORS: > fatal_errors = 1; > break; > @@ -1453,6 +1476,15 @@ static void set_params(void) > stop_threshold = (double) rate * stop_delay / 1000000; > err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, stop_threshold); > assert(err >= 0); > + if (enable_tstamp) { > + err = snd_pcm_sw_params_set_tstamp_mode(handle, swparams, SND_PCM_TSTAMP_ENABLE); > + assert(err >= 0); > + err = snd_pcm_sw_params_set_tstamp_type(handle, swparams, tstamp_type); > + if (err < 0) { > + error(_("Unable to set the requested timestamp type.")); > + prg_exit(EXIT_FAILURE); > + } > + } > > if (snd_pcm_sw_params(handle, swparams) < 0) { > error(_("unable to install sw params:")); > -- > 2.25.1 Regards Takashi Sakamoto