[pulseaudio-discuss] playback latency information

Lennart Poettering lennart at poettering.net
Wed Feb 17 08:02:21 PST 2010


On Fri, 22.01.10 15:26, pl bossart (bossart.nospam at gmail.com) wrote:

> This is probably a question for Lennart...
> 
> I am somewhat confused on how the playback latency should be
> estimated. I was under the impression that pa_stream_get_latency() was
> the way to go, but I came across some code in gstreamer/pulsesink
> where the latency is retrieved with pa_stream_get_timing_info()

The gst driver used to do things like that when I wrote it. Wim might
have changed that, when he made some major changes to it.

> I however cannot figure out what the fields pa_timing_info::sink_usec
> and ::configured_sink_used mean, and whether they have any
> relationship with the values returned by pa_stream_get_latency(). In
> my tests, I see the following values in the latency_cb() routine

configured_sink_usec is mostly informational. If a client asks for a
specific latency, then this has an effect on the latency the sink is
configured to. This parameter will tell you to which.

Normally the actually measured sink latency should always stay below
the configured_latency, but that is mandatory, because the configured
latency actually configures the playback buffer size and sink_usec
includes the entire sink latency, including any additional latencies
"behind" the playback buffer.

> sink latency 0, configured_sink_usec 90000 sink_usec 0
> sink latency 0, configured_sink_usec 90000 sink_usec 87213
> sink latency 0, configured_sink_usec 90000 sink_usec 86998
> sink latency 0, configured_sink_usec 90000 sink_usec 86724
> sink latency 242259, configured_sink_usec 90000 sink_usec 88696
> sink latency 482473, configured_sink_usec 90000 sink_usec 88568
> sink latency 473523, configured_sink_usec 90000 sink_usec 90064
> sink latency 477102, configured_sink_usec 90000 sink_usec 89338
> 
> Which of these three values shall be provided to the gstreamer (or
> other middleware) pipeline to represent the back-end delay?

Generally clients should not try to outsmart PA and depend on
_get_latency() or _get_time() for timing which will distill the timing
from all timing information available.

The configured_sink_usec is only an unreliable indication about the
range sink_usec will be in.

sink_usec will contain the latency of the hardware playback buffer,
and all buffers "behind" it in the hardware, but not include the
per-stream playback buffers or anything that is currently in flux.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list