Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Rajagopal Aravindan <a.rajagopal.81@gmail.com>,
	alsa-devel@alsa-project.org
Subject: Re: Playback samples at a specific time on Intel HDA
Date: Thu, 21 Feb 2019 15:16:26 -0600	[thread overview]
Message-ID: <2f19262d-f37f-8d43-de76-9bdb82c11d84@linux.intel.com> (raw)
In-Reply-To: <CAEQQSVuKc-vZKaeg9xUmYpnBYfsCZYLpr5AkpA26KysUZLe_Vg@mail.gmail.com>



> I am trying to accomplish synchronized audio playback using ALSA &
> gPTP, on an Intel SkyLake platform have Intel HDA.
That's an ambitious goal, I hope you are aware of the technical 
complexity behind this one-line problem description.
>
> I do understand that, starting with SkyLake platform, there is support
> for querying link time.
That's correct.
> But, how do I instruct to play the samples at a given (gPTP) time ?
> Is this possible ?

Unfortunately this is not possible, the hardware doesn't provide such 
synchronization capabilities. ALSA provide timestamps, so does gPTP and 
you need a userspace part to tie them together. The only thing you can 
do is start a silent stream, query the system/audio synchronized 
timestamp and based on the information insert the samples at the 
relevant position. That latter part is unfortunately not very precise 
and will typically be impacted by the position of the DMA pointer. The 
timestamps are also only at the link level, and the delays introduced by 
the analog parts is also not modeled anywhere - and codec vendors 
usually don't provide this information.

You also want to take the audio timestamps in ns with a grain of salt, 
it turns out that the conversion uses a nominal value which introduces a 
bias compared to the actual value. This will be compensated for if your 
userspace component tracks clock drift.

> Can someone please point me to code or doc, relevant to my goal ?
> In essence, I would like to play the samples at the stroke of a given
> (gPTP) time.
>
> Also, the ALSA page says ...
> "The link time can be directly measured if supported in hardware by
> sample counters or wallclocks (e.g. with HDAudio 24MHz or PTP clock
> for networked solutions)"
>
> What is the connection between PTP clock and sound card here,
> are there sound cards that can latch on to a PTP clock on a NIC or what ?
There is no connection on an HDaudio platform. The audio clock is based 
on the 24 MHz PLL which is independent from any network clock.

      reply	other threads:[~2019-02-21 21:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21 19:19 Playback samples at a specific time on Intel HDA Rajagopal Aravindan
2019-02-21 21:16 ` Pierre-Louis Bossart [this message]

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=2f19262d-f37f-8d43-de76-9bdb82c11d84@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=a.rajagopal.81@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    /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