All of lore.kernel.org
 help / color / mirror / Atom feed
* Frame-based access (via mmap) and cross-device synchronisation
@ 2009-07-20 14:03 Metathronius Galabant
  2009-07-21 13:49 ` Clemens Ladisch
  0 siblings, 1 reply; 2+ messages in thread
From: Metathronius Galabant @ 2009-07-20 14:03 UTC (permalink / raw)
  To: alsa-devel

Hi all,

I could not find any examples, plus the alsa documentation and the
pcm.c example on mmap-style access is rather slim.
Consider the following setting:

I have 2 seperate HW devices that are NOT clock sync'ed; their period
is set to 10ms, and the total SW buffer is set to 20ms (= classic
double buffering) or 40ms.
Now I need to read from the 1st device and write to the 2nd device -
and read from the 2nd device and write to the 1st device.

Now, to synchronise - because their clocks do drift - I'd like to have
the following semantics:

At any given time x0, x1, ... xn I'd like to take some kind of
"snapshot" of both devices, ask them "how many frame do you have?".
This MUST NOT be restricted to the period, but it should be like
device1 has 80 frames, device2 only has 78 frames. In short I would
need pure frame-based access at any given time.
I will then manually discard or duplicate frames to keep both streams happy.

How do I achieve this kind of access method via alsa?

Any help is welcome. Thanks!
M.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Frame-based access (via mmap) and cross-device synchronisation
  2009-07-20 14:03 Frame-based access (via mmap) and cross-device synchronisation Metathronius Galabant
@ 2009-07-21 13:49 ` Clemens Ladisch
  0 siblings, 0 replies; 2+ messages in thread
From: Clemens Ladisch @ 2009-07-21 13:49 UTC (permalink / raw)
  To: Metathronius Galabant; +Cc: alsa-devel

Metathronius Galabant wrote:
> At any given time x0, x1, ... xn I'd like to take some kind of
> "snapshot" of both devices, ask them "how many frame do you have?".
> This MUST NOT be restricted to the period, but it should be like
> device1 has 80 frames, device2 only has 78 frames.

Call snd_pcm_avail().  The granlarity of its return value is device
specific; e.g., chips like Emu10k1 or DS-1 move data in blocks of 256
or 512 samples, and USB uses 1-ms frames.  You are not guaranteed to
get a result that is more recent than the last period boundary,
although most devices can do better.


Best regards,
Clemens

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-21 13:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-20 14:03 Frame-based access (via mmap) and cross-device synchronisation Metathronius Galabant
2009-07-21 13:49 ` Clemens Ladisch

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.