Skip to content

Instantly share code, notes, and snippets.

@lawl
Created July 20, 2020 17:01
Show Gist options
  • Save lawl/9e539d4ba1cf40a19e251ecbdb9a0f8c to your computer and use it in GitHub Desktop.
Save lawl/9e539d4ba1cf40a19e251ecbdb9a0f8c to your computer and use it in GitHub Desktop.
From 257e4063778cc7454cdc15f69aeb1c32467d3b71 Mon Sep 17 00:00:00 2001
From: Georg Chini <georg@chini.tk>
Date: Mon, 20 Jul 2020 18:50:21 +0200
Subject: [PATCH] loopback: Fix sink latency calculation if source is alsa
source with fixed latency
When an alsa source with fixed latency is used, the actual latency of the source
will only be one fragment size. This is not taken into account when the required
sink latency is calculated.
This patch fixes the issue.
---
src/modules/module-loopback.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c
index ed559e4c7..b07e02383 100644
--- a/src/modules/module-loopback.c
+++ b/src/modules/module-loopback.c
@@ -1016,6 +1016,8 @@ static void set_sink_input_latency(struct userdata *u, pa_sink *sink) {
if (u->min_source_latency > requested_latency) {
latency = PA_MAX(u->latency, u->minimum_latency);
requested_latency = (latency - u->min_source_latency) / 2;
+ if (u->fixed_alsa_source)
+ requested_latency = PA_MIN(requested_latency, (latency - u->core->default_fragment_size_msec * PA_USEC_PER_MSEC) / 2);
}
latency = PA_CLAMP(requested_latency , u->min_sink_latency, u->max_sink_latency);
--
2.25.0.rc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment