« Return to Thread: jack (1 and 2) latency reporting

Re: jack (1 and 2) latency reporting

by Fons Adriaensen-2 :: Rate this Message:

| View in Thread

On Thu, Dec 09, 2010 at 09:48:00PM +0100, Robin Gareus wrote:

>  ALSA: use 3 periods for capture
>  ALSA: use 3 periods for playback
>
> = 6 periods of total latency

No, 3.
 
> != ( 1024 + 2048 ) / 1024 = 3 periods total latency

-n 3 means that the sample buffers for both capture and
playback are 3 periods long. Asssume for a moment these
are the actual HW buffers, as coild well be the case for
e.g. a PCI card.

Let the period size be N.

At the end of each period the soundcard will generate
an interrupt to the driver. The application (e.g. jack)
wakes up and assuming it uses ALSA's mmap interface it
gets two pointers into the HW buffers:

* The capture pointer points to first of the N input samples
  that have  been input during the period preceding the last
  interrupt. The app is supposed to use these as input. In
  the meantime, the HW will write to the next period in the
  capture buffer.

  For -n 2, the app must read this data before the next
  interrupt, as otherwise they will be overwritten by
  the HW.
  For -n 3, the app has one more period to read the data.
  For -n 4, the app has two extra periods, etc.

* The playback pointer points to the first of the N output
  samples that have been output during the period preceding
  last interrupt. The app is supposed to overwrite these
  with new data. In the meantime, the HW will output the
  next period in the playback buffer.

  For -n 2, this must be done before the next interrupt,
  as otherwise the HW will re-use old data for output.
  For -n 3, the app has one more period to supply the
  new data.
  For -n 4, the app has two extra periods, etc.

Now imagine an app that just copies the data at the capture
pointer to the playback pointer. Make some drawings to help
you imagine what happens. The conclusion will be that any
input signal will re-appear at the output after K periods
where K is the number of periods in the buffers.

Ciao,

--
FA

There are three of them, and Alleline.

_______________________________________________
Jack-Devel mailing list
Jack-Devel@...
http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org

 « Return to Thread: jack (1 and 2) latency reporting