[alsa-devel] Control the exact moment of output
clemens at ladisch.de
Tue Apr 29 09:50:53 CEST 2014
Rob Janssen wrote:
> For a distributed system that requires synchronized output I would like to determine
> the exact moment when output samples are sent, preferably within +/- 1 sample time.
> Is this possible within the ALSA API?
In theory, yes; snd_pcm_delay() should take these latencies into account.
In practice, there is no hardware where this value is accurate. Drivers with
large latencies (e.g., USB) report their internal queues, but nobody bothers
for the small delays (about 10 samples) in the DMA controllers and DACs.
> Are some types of soundcard more suitable than others for this purpose?
PCI(e) cards have lower latencies, but if you configure two USB devices
with the same parameters, the driver's queues will have the same length.
> And are there soundcards available where the sample clock can somehow be
> locked to system time or an external 10MHz/1PPS reference?
Some cards can be locked to an S/PDIF input or to a word clock from another
sound card. This does not work for physically separated outputs; you'd have
to measure the clock differences and do dynamic resampling.
More information about the Alsa-devel