All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Cussins <timcussins@eml.cc>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	alsa-devel@alsa-project.org
Subject: Re: proposal: snd_pcm_start_at()
Date: Fri, 03 Oct 2014 13:00:36 +0100	[thread overview]
Message-ID: <542E8FE4.4080904@eml.cc> (raw)
In-Reply-To: <542D8E3F.4080400@linux.intel.com>

Hi Peirre,

On 02/10/14 18:41, Pierre-Louis Bossart wrote:
> 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

Thanks heaps for the feedback :)

Agreed - streaming zeros 'as required' is pretty much the obvious 
solution when confined to the existing API.

So I guess I'll have to show a few more cards from my hand :D

The next iteration of our hardware platform will be accompanied by a 
move to linux, which explains our interest in ALSA for sound delivery.

The pcm hardware for the new platform can start rendering when a compare 
register matches a hw counter (driven by the audio clock). This allows 
for starting with frame-accurate timing.

By adding another tstamp_type - let's call it 
SND_PCM_TSTAMP_TYPE_HARDWARE for now - snd_pcm_start_at() could 
internally delegate to the driver (if it supports it, otherwise error)

I take your point about drift, but we're approaching that as a related, 
but orthogonal, problem. As a business we've decided that dropouts are 
unacceptable. Our products have several audio clock sources available, 
one of which is a high-quality VXCO. With an appropriate servo, it will 
track a clock recovered from the incoming stream.

I'm still working through a couple of options for exposing the VXCO 
audio clock to a userspace servo [The linux kernel has the PCH 
framework, for example, which is almost enough, but doesn't dovetail 
with ALSA in an obvious way].

In summary, we'd like to leverage our pcm hardware's ability to start on 
time (hence the chat about snd_pcm_start_at), and we'd also like to 
expose control of the pcm's audio clock in some way (WIP, suggestions 
welcome!).

The clock control stuff is harder, but I wanted to get on the ml with 
something simple, say hi, propose a thing

Thanks for reading - I'll have questions about clock control soon 
enough, see ya then.

Cheers,
Tim

  reply	other threads:[~2014-10-03 12:00 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
2014-10-03 12:00   ` Tim Cussins [this message]
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=542E8FE4.4080904@eml.cc \
    --to=timcussins@eml.cc \
    --cc=alsa-devel@alsa-project.org \
    --cc=pierre-louis.bossart@linux.intel.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 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.