Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Tim Cussins <timcussins@eml.cc>, alsa-devel@alsa-project.org
Subject: Re: proposal: snd_pcm_start_at()
Date: Thu, 02 Oct 2014 12:41:19 -0500	[thread overview]
Message-ID: <542D8E3F.4080400@linux.intel.com> (raw)
In-Reply-To: <1412260460.3891605.174362449.667FB9BE@webmail.messagingengine.com>

On 10/2/14, 9:34 AM, Tim Cussins wrote:
> Hi all,
>
> I'm Tim: I work at Linn Products Ltd - we make Network Music Players,
> amongst other things.
>
> As you might imagine, synchronised-start is important when multiple
> devices on the network are rendering the same audio. We'd be interested
> in contributing a small expansion of the alsa-lib API to support
> synchronised start.
>
> Assuming we can synchronise the audio clocks (I'm aware this is not
> trivial - It's not the topic of this post), we'd propose something like:
>
>      int snd_pcm_start_at(snd_pcm_t* pcm, snd_htimestamp_t* tstamp);
>
> and playback would begin as close to tstamp as possible. If tstamp is in
> the past, it would should return an error.
>
> Recent work by Takashi Iwai enables client code to set the clock type of
> timestamps using snd_pcm_sw_params_set_tstamp_type(). This context could
> quite naturally extend to tstamp argument of snd_pcm_start_at().
>
> Before I get stuck into working up the details under the hood, it'd be
> good to get some feedback/objections regarding this approach.

It's probably better idea to start PCM playback with a bunch of zeroes 
and then rely on existing timestamping to insert samples at the right 
location in the ring buffer - which you have to do anyway to compensate 
for drifts between your network clock and audio clock. This is a more 
predictable solution that abstracts away all the time needed to arm DMA, 
FIFOs, etc. The only hardware-dependent variable that would remain is 
the precision/granularity of the timestamping.
-Pierre

  reply	other threads:[~2014-10-02 17:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02 14:34 proposal: snd_pcm_start_at() Tim Cussins
2014-10-02 17:41 ` Pierre-Louis Bossart [this message]
2014-10-03 12:00   ` Tim Cussins
2014-10-03 22:24     ` Pierre-Louis Bossart
2014-10-06  9:45       ` Takashi Iwai
2014-10-07 12:48         ` Tim Cussins
2014-10-08 14:18         ` Mark Brown
2014-10-08 15:29           ` Takashi Iwai
2014-10-08 16:09             ` Tim Cussins
2014-10-08 20:16               ` Mark Brown
2014-10-09  9:20                 ` Tim Cussins
2014-10-10 19:50                   ` Nick Stoughton

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=542D8E3F.4080400@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=timcussins@eml.cc \
    /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