Skip to contentSkip to conversation

IO streams sync

DISCUSSION alejandro 3 participants 3 messages Jun 19, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

alejandro

author
#1 lore raw

Hello,

Is there any document describing the ALSA components and functions? Particularly the link between audio I/O and timers, in order to frame accurate sync multiple audio cards and video.

Thank you,

Signature · 3 lines
Alejandro Palencia
Open Studio Networks
+34 932054354
#2 lore raw
Quoted 5 lines · alejandro

Hello,

Is there any document describing the ALSA components and functions? Particularly the link between audio I/O and timers, in order to frame accurate sync multiple audio cards and video.

You probably want to be using JACK for this. ALSA is just a low level HAL. There are some patches floating around that add video capabilities ("videojack").

Lee

#3 lore raw
In reply to alejandro
Quoted 8 lines · alejandro

Hello,

Is there any document describing the ALSA components and functions? Particularly the link between audio I/O and timers, in order to frame accurate sync multiple audio cards and video.

Thank you,

Alejandro,

This is achieved using the snd_pcm_delay() function call.
It gives you a measure of the number of samples between the current write pointer and the codec output.
I.e. If you call snd_pcm_writei() now, it will be snd_pcm_delay() sample frames duration until the sample reach the speakers.
So, from that you can accurately predict the exact time that a particular sample will reach the speakers, and therefore keep video in sync with it.
This method is used in xine (http://xinehq.de)
See the audio_out.c loop.

One then combines this with a resampler (as xine does), to adjust for clock speed differences between sound cards and the system timer, so this prevents sync drift.

James