audiolatency Plugin Values Shows High Values In Certain Cases

Abrar Shahriar abrar.shahriar at hiperdyne.com
Tue May 24 06:48:59 UTC 2022


Mystery solved, thanks so much.

-Abrar



ーーーーーーーーー

アブラル・ザヒン・シャハリアル  (Abrar Zahin Shahriar)

ハイパーダイン株式会社
〒108-0014 東京都港区芝5丁目9-12 3階

________________________________
From: Nirbheek Chauhan <nirbheek.chauhan at gmail.com>
Sent: Tuesday, May 24, 2022 3:46 PM
To: Discussion of the development of and with GStreamer <gstreamer-devel at lists.freedesktop.org>
Cc: Abrar Shahriar <abrar.shahriar at hiperdyne.com>
Subject: Re: audiolatency Plugin Values Shows High Values In Certain Cases

Hi Abrar,

With autoaudiosrc and autoaudiosink, the pipeline will automatically plug appropriate elements with default configuration. For instance on my system this is what it looks like:

$ gst-launch-1.0 autoaudiosrc ! audiolatency print-latency=true ! autoaudiosink
[...]
last latency: 7ms, running average: 7ms
last latency: 190ms, running average: 99ms
last latency: 178ms, running average: 125ms
last latency: 195ms, running average: 143ms
last latency: 172ms, running average: 149ms
last latency: 194ms, running average: 186ms
last latency: 195ms, running average: 187ms
last latency: 188ms, running average: 189ms
last latency: 190ms, running average: 188ms

If we directly use the elements auto-plugged by autoaudiosrc / autoaudiosink, we get the same latency:

$ gst-launch-1.0 pulsesrc  ! audiolatency print-latency=true ! pulsesink
[...]
last latency: 191ms, running average: 191ms
last latency: 189ms, running average: 190ms
last latency: 204ms, running average: 195ms
last latency: 190ms, running average: 194ms
last latency: 182ms, running average: 191ms
last latency: 180ms, running average: 189ms
last latency: 176ms, running average: 186ms

But if we tweak the appropriate properties, the latency goes down:

$ gst-launch-1.0 pulsesrc buffer-time=20000 latency-time=10000 ! audiolatency print-latency=true ! pulsesink buffer-time=20000 latency-time=10000
last latency: 14ms, running average: 14ms
last latency: 60ms, running average: 37ms
last latency: 58ms, running average: 44ms
last latency: 58ms, running average: 48ms
last latency: 52ms, running average: 48ms
last latency: 52ms, running average: 56ms

buffer-time and latency-time control parameters for the audio ringbuffer. buffer-time is the total size of the ringbuffer (max-latency) and latency-time is the size of each read / write to that ringbuffer (min-latency). The lowest possible values depend on the audio hardware, audio drivers, sound server, real-time priority of the app, available CPU, etc.

You will get the lowest latency with pipewire or JACK on Linux, wasapi2 or ASIO on Windows, and CoreAudio (osxaudiosrc / sink) on macOS.

With wasapi, wasapi2, and jack you can set low-latency=true to ask the element to auto-configure to a low latency value.

Cheers,
Nirbheek

On Mon, May 23, 2022 at 3:30 PM Abrar Shahriar via gstreamer-devel <gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>> wrote:
Hi,

I have been using audiolatency with some custom Gst apps, it usually shows 40-50ms, but when using the sample cmd line pipeline (

gst-launch-1.0 -v autoaudiosrc ! audiolatency print-latency=true ! autoaudiosink

), it shows around 200-300ms.

I made a custom app mirroring the sample pipeline, this app also shows 200-300ms.

There is usually a big jump after the first print like so-
last latency: 44ms, running average: 44ms
last latency: 1025ms, running average: 535ms
last latency: 175ms, running average: 415ms
last latency: 215ms, running average: 365ms
last latency: 173ms, running average: 326ms
​What is the mechanism behind this? Is there a way to constantly get 40-50ms?

-Abrar

ーーーーーーーーー

アブラル・ザヒン・シャハリアル  (Abrar Zahin Shahriar)

ハイパーダイン株式会社
〒108-0014 東京都港区芝5丁目9-12 3階
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220524/8b0e3dc9/attachment-0001.htm>


More information about the gstreamer-devel mailing list