All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: sylvain.bertrand@gmail.com, Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org,
	Kai Vehmanen <kai.vehmanen@linux.intel.com>
Subject: Re: sw_params for a direct-ed(dmix) hw pcm
Date: Sat, 28 Mar 2020 14:15:34 -0500	[thread overview]
Message-ID: <1baab0fd-d802-3707-645f-d5dc4bf6c32c@linux.intel.com> (raw)
In-Reply-To: <20200328182624.GA775@freedom>



On 3/28/20 1:26 PM, sylvain.bertrand@gmail.com wrote:
> On Fri, Mar 27, 2020 at 10:40:06AM +0100, Jaroslav Kysela wrote:
>> Yes, it's a bug which should be fixed in dmix instead to use a workaround in
>> the app. The easiest way is to return an error in set sw_params, but it may
>> cause problems for the app which assumes that this timestamp mode can be set
>> freely. Perhaps, we can add a timestamp translation layer (not easy, I
>> know).
> 
> I understand that, in the case of a shared hw, reasonable defaults should be
> enforce to avoid that any audio application which would be first to configure
> this hw and throwing some audio configuration tantrum, forces it upon all the
> other audio applications (this is the answer to "why has dmix some defaults?").
> 
> Speaking strictly, snd_pcm_sw_params_set_tstamp_type() has a return
> value, namely application code must expect a return code which could be an
> error code. Additionnaly an audio app using the kernel interface/a hw plugin
> pcm, would have to track anyway the type of timestamp clock at the time of state
> change: the trigger timestamp of a kernel status ioctl used the type of
> timestamp clock at the time of the state change, not the type of timestamp
> clock provided in the ioctl (btw, what about some documentation addition?).
> 
> In the use case of a shared device, it seems the right way would be to send an
> error back to the application (aka "making snd_pcm_sw_params_set_tstamp_type()
> recurse down the plugin pipeline"), because after giving some thoughts about it
> I don't see how it is possible to convert a timestamp from one clock type to
> another: backlog all adjtime deltas, plus the initial values, plus any natural
> drift? The linux devs in charge of time keeping may be able to answer this.

I don't think it's possible unless the timestamps are taken really close 
to each other. There was some work some by Chris Hall in 2016 to revisit 
how the conversions were done and the past taken into account is a 
couple of ms, see ("time: Add history to cross timestamp interface 
supporting slower devices").

if your device is "shared", which implies a mixer, the notion of precise 
timestamps is rather questionable so you might be able to get-by with 
local interpolation in your plug-ins. Trying a full-blown conversion of 
the kernel-reported time is not really useful if the mixing granularity 
is in the ms range or more.

FWIW you also want to take MONOTONIC_RAW with a grain of salt. In a 
corner case w/ long tests lasting 48 hours we saw the timestamps 
reported by the kernel drift over time. the drift was minor 
(double-digit ppb - yes parts per billion) but the fixed-point math for 
the counters at some point impacts the results. Reading directly the TSC 
from userspace and doing floating-point math bypassed the rounding errors.

  reply	other threads:[~2020-03-28 19:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-21 15:53 monotonic raw setup seems buggy sylvain.bertrand
2020-03-25 17:44 ` sw_params for a direct-ed(dmix) hw pcm sylvain.bertrand
2020-03-26 12:02   ` Kai Vehmanen
2020-03-26 14:36     ` Jaroslav Kysela
2020-03-26 20:04       ` sylvain.bertrand
2020-03-27  8:08         ` Takashi Iwai
2020-03-27  9:40           ` Jaroslav Kysela
2020-03-28 18:26             ` sylvain.bertrand
2020-03-28 19:15               ` Pierre-Louis Bossart [this message]
2020-03-28 20:37                 ` sylvain.bertrand
2020-03-28 21:34                   ` Pierre-Louis Bossart
2020-03-28 22:20                     ` sylvain.bertrand
2020-03-29  7:43                       ` Takashi Iwai
2020-03-31 11:32                         ` Takashi Iwai
2020-04-01 15:25                           ` sylvain.bertrand
2020-04-01 15:59                             ` Takashi Iwai
2020-04-01 20:21                               ` sylvain.bertrand
2020-04-02 19:03                                 ` sylvain.bertrand
2020-04-06 13:49                                   ` sylvain.bertrand
2020-04-14 15:18                                     ` Takashi Iwai
2020-04-14 23:20                                       ` sylvain.bertrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1baab0fd-d802-3707-645f-d5dc4bf6c32c@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=perex@perex.cz \
    --cc=sylvain.bertrand@gmail.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.