All of lore.kernel.org
 help / color / mirror / Atom feed
* IO streams sync
       [not found] <mailman.3908.1150727591.2958.alsa-devel@lists.sourceforge.net>
@ 2006-06-19 16:17 ` alejandro
  2006-06-19 16:21   ` Lee Revell
  2006-06-19 19:05   ` James Courtier-Dutton
  0 siblings, 2 replies; 5+ messages in thread
From: alejandro @ 2006-06-19 16:17 UTC (permalink / raw)
  To: alsa-devel

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 Palencia
Open Studio Networks
+34 932054354

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

* Re: IO streams sync
  2006-06-19 16:17 ` IO streams sync alejandro
@ 2006-06-19 16:21   ` Lee Revell
  2006-06-19 19:05   ` James Courtier-Dutton
  1 sibling, 0 replies; 5+ messages in thread
From: Lee Revell @ 2006-06-19 16:21 UTC (permalink / raw)
  To: alejandro; +Cc: alsa-devel

On Mon, 2006-06-19 at 18:17 +0200, alejandro wrote:
> 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

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

* Re: IO streams sync
  2006-06-19 16:17 ` IO streams sync alejandro
  2006-06-19 16:21   ` Lee Revell
@ 2006-06-19 19:05   ` James Courtier-Dutton
  1 sibling, 0 replies; 5+ messages in thread
From: James Courtier-Dutton @ 2006-06-19 19:05 UTC (permalink / raw)
  To: alejandro; +Cc: alsa-devel

alejandro wrote:
> 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

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

* IO streams sync
       [not found] <mailman.4401.1150734905.2958.alsa-devel@lists.sourceforge.net>
@ 2006-06-20 10:38 ` alejandro
  2006-06-20 20:18   ` James Courtier-Dutton
  0 siblings, 1 reply; 5+ messages in thread
From: alejandro @ 2006-06-20 10:38 UTC (permalink / raw)
  To: alsa-devel

Lee Revell escribió:

>On Mon, 2006-06-19 at 18:17 +0200, alejandro wrote:
>  
>
>>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
>
>  
>
James Courtier-Dutton escribió:

>alejandro wrote:
>
>>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
>
>
>

Lee and James,

It is not possible to sync two interfaces if we don't have timestamped
frame numbering (UST/MSC pairs). That means that we need to know, from a
common clock, the time at which a (numbered) frame will be output or was
input from a jack. Current time is not usable, because obviously there
is an unknown delay between function calls. If the system is not able to
produce timestamp/frame count pairs, there is no possibility to sync
audio streams or audio to video streams. I have looked at JACK, and the
situation is the same as with the ALSA API.

There are cards in the market with such timestamped operations supported
in the hardware and proprietary APIs, but is there a way to accessing
these operations from ALSA or JACK?

Thank you,

Alejandro


-- 
Alejandro Palencia
Open Studio Networks
+34 932054354

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

* Re: IO streams sync
  2006-06-20 10:38 ` alejandro
@ 2006-06-20 20:18   ` James Courtier-Dutton
  0 siblings, 0 replies; 5+ messages in thread
From: James Courtier-Dutton @ 2006-06-20 20:18 UTC (permalink / raw)
  To: alejandro; +Cc: alsa-devel

alejandro wrote:
>>
> 
> Lee and James,
> 
> It is not possible to sync two interfaces if we don't have timestamped
> frame numbering (UST/MSC pairs). That means that we need to know, from a
> common clock, the time at which a (numbered) frame will be output or was
> input from a jack. Current time is not usable, because obviously there
> is an unknown delay between function calls. If the system is not able to
> produce timestamp/frame count pairs, there is no possibility to sync
> audio streams or audio to video streams. I have looked at JACK, and the
> situation is the same as with the ALSA API.
> 
> There are cards in the market with such timestamped operations supported
> in the hardware and proprietary APIs, but is there a way to accessing
> these operations from ALSA or JACK?
> 
> Thank you,
> 
> Alejandro
> 
> 

I think you are wrong. Just take a look at xine playing a DVD. The audio
and video are in perfect sync. It can be done with the current API.

James

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

end of thread, other threads:[~2006-06-20 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.3908.1150727591.2958.alsa-devel@lists.sourceforge.net>
2006-06-19 16:17 ` IO streams sync alejandro
2006-06-19 16:21   ` Lee Revell
2006-06-19 19:05   ` James Courtier-Dutton
     [not found] <mailman.4401.1150734905.2958.alsa-devel@lists.sourceforge.net>
2006-06-20 10:38 ` alejandro
2006-06-20 20:18   ` James Courtier-Dutton

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.