From: Alan Young <consult.awy@gmail.com>
To: Raymond Yau <superquad.vortex2@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: Improving status timestamp accuracy
Date: Mon, 6 Jun 2016 10:40:32 +0100 [thread overview]
Message-ID: <57554510.9070700@gmail.com> (raw)
In-Reply-To: <CAN8cciab89x5ZQaBkSAGxEOzQ7FB3ORJAcd47Gu6EjSVDmk2cA@mail.gmail.com>
On 06/06/16 02:24, Raymond Yau wrote:
> http://git.alsa-project.org/?p=alsa-lib.git;a=commitdiff;h=cf40ea169aad366b222283f431addafea6327149;hp=4bdb09126a32feb4394eaeb1d400d87e7c968770
>
> HDA has hardware specific feature (audio wallclock) for the timestamp
> and period wakeup can be disabled
>
>
> only a few pci drivers which read the residue value from hardware
> register (e.g. hda-intel, oxygen , .) you have to measure the
> granularity since the unit may be different for usb, pcie and firewire
> sound card
>
Thank you Raymond. Yes, (I think) I understand all that. Let me restate
my understanding of the situation.
The pointer position will generally be inaccurate by up to a period
size. Even when a driver claims to support
DMA_RESIDUE_GRANULARITY_BURST, the reported data is still unlikely to be
sample accurate (as the size of a burst is undefined). For most drivers
the reported position will be inaccurate and the actual accuracy cannot
be determined.
The delay is also likely to be inaccurate. It is intended that this
could include things such as codec delay but for most drivers this is
not included. A few drivers, and in particular USB via an estimate, do
try to include the in-flight transfer delay. In some ways this is the
worst case: the delay may or may not include the transfer delay AND may
or may not include the codec delay; what it actually includes is unknown.
The result of these is that both the position and delay may be
inaccurate and the degree to which this is the case is not known.
We can tell that the position has not changed since the last call to
snd_pcm_update_hw_ptr0() because new_hw_ptr == old_hw_ptr. We can use
this knowledge to adjust the audio_tstamp returned by the time elapsed
since the previous call (for SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT). We
can also make such an adjustment even if the position has changed to
better deal with the inaccuracy of position reporting.
Because of the 2 different types of unknown accuracy in delay, we cannot
do the same trick with this. In many ways being able to update the delay
in this way would be ideal. If we could, then we could leave
audio_tstamp alone and let audio_tstamp_config.report_delay determine if
the adjusted delay is also included in that. Since, in practice, most
drivers either contain no codec delay value of a constant one, we can
still use such a mechanim for most practical cases.
Have I got anything wrong above?
I'm going to test a revised patch based on these assumptions.
>
> as the application is based on the pointer for read/write, you still
> need to use small period size and CPU power if you want to determine
> the value returned by snd_pcm_rewindable is safe or not
My point is that I want to find a way to get reported delay and/or audio
timestamps that are more accurate that a period time even in the absence
of hardware that has specific support for this.
Alan.
next prev parent reply other threads:[~2016-06-06 9:40 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-04 9:31 Improving status timestamp accuracy Alan Young
2016-06-04 10:17 ` Clemens Ladisch
2016-06-04 10:43 ` Alan Young
2016-06-04 15:59 ` Clemens Ladisch
2016-06-04 16:20 ` Alan Young
2016-06-05 16:27 ` Clemens Ladisch
2016-06-05 16:32 ` Alan Young
2016-06-05 1:14 ` Raymond Yau
2016-06-05 10:33 ` Alan Young
2016-06-06 1:24 ` Raymond Yau
2016-06-06 9:40 ` Alan Young [this message]
2016-06-06 8:34 ` Takashi Iwai
2016-06-06 9:42 ` Alan Young
2016-06-06 14:53 ` Pierre-Louis Bossart
2016-06-07 6:44 ` Alan Young
2016-06-07 18:01 ` Pierre-Louis Bossart
2016-07-08 15:03 ` Alan Young
2016-07-15 20:13 ` Pierre-Louis Bossart
2016-07-19 15:33 ` Alan Young
2016-07-19 15:58 ` Pierre-Louis Bossart
2016-07-20 6:59 ` Alan Young
2016-08-01 21:56 ` Pierre-Louis Bossart
2016-08-02 7:30 ` Alan Young
2016-08-02 7:55 ` Clemens Ladisch
2016-08-02 16:25 ` Pierre-Louis Bossart
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=57554510.9070700@gmail.com \
--to=consult.awy@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=superquad.vortex2@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).