Closed tmigone closed 3 years ago
As seen in adjust_rates
function here the loopback module's latency is increased by 5 msec every time that the underrun count gets to 3, no matter how big the base rate latency is. So as long as underruns keep happening it will keep increasing by 5 msec until it reaches parity.
19.11.20 18:47:03 (-0300) audio D: [pulseaudio] module-loopback.c: Loopback overall latency is 63.32 ms + 150.91 ms + -13.99 ms = 200.14 ms
19.11.20 18:47:03 (-0300) audio D: [pulseaudio] module-loopback.c: Loopback latency at base rate is 200.14 ms
19.11.20 18:47:03 (-0300) audio D: [pulseaudio] module-loopback.c: [alsa_output.bcm2835-jack.stereo-fallback] Updated sampling rate to 44100 Hz.
19.11.20 18:47:03 (-0300) audio W: [pulseaudio] module-loopback.c: Too many underruns, increasing latency to 320.00 ms
19.11.20 18:47:03 (-0300) audio D: [pulseaudio] module-loopback.c: Loopback overall latency is 315.03 ms + 43.36 ms + -8.81 ms = 349.46 ms
19.11.20 18:47:03 (-0300) audio D: [pulseaudio] module-loopback.c: Loopback latency at base rate is 349.50 ms
19.11.20 18:47:03 (-0300) audio D: [pulseaudio] module-loopback.c: [snapcast] Updated sampling rate to 44200 Hz.
This seems to be happening usually with the loopback module that hast snapcast
as sink (so sadly another instance of the FIFO pipe file/snapcast slowing things down):
Module #26
Name: module-loopback
Argument: source="balena-sound.input.monitor" sink="snapcast"
Usage counter: n/a
Properties:
module.author = "Pierre-Louis Bossart"
module.description = "Loopback from source to sink"
module.version = "13.0"
Workaround
Loopback modules use 200 msec as the starting latency (code, docs). That value can be overridden by setting the latency_msec
when the loopback module is declared. In the case of balenaSound this needs to be adjusted here with a latency value that matches whatever value it stabilised at.
Note that this workaround is not fixing the problem but rather hiding it.
Resolution
This affects each application differently so there is no changes to be made to the audio block.
For balenaSound, PR #356 addresses this problem:
SOUND_INPUT_LATENCY
environment variable which directly adjusts latency_msec
parameter.
Using this issue to track the underruns investigation. The warning that gets logged:
Related links: