summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Chini <georg@chini.tk>2019-03-26 10:31:24 +0100
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>2021-08-25 15:32:22 +0000
commit9d1a43ae8d21e17001cfd061ede432ba4ba4cefe (patch)
treebba2e7c535c5cc6a1a5d9d9b30786195500e5b98
parent54baa223bb76d1b9cde3ef4ca56ccbef1c02ed8c (diff)
combine-sink: Improve initial latency reports
Currently, it takes one adjust time before the smoother is updated after an unsuspend. Before the first update, the smoother will not be aware of the slave sink latencies, leading to incorrect latency reports. This patch moves the first smoother update to one latency time after the sink was unsuspended, thereby improving initial latency reports. This only partially resolves the problem because the smoother takes multiple updates to adapt to the slave sink latencies. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/53>
-rw-r--r--src/modules/module-combine-sink.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c
index 23fb9ce0f..c27a77ee2 100644
--- a/src/modules/module-combine-sink.c
+++ b/src/modules/module-combine-sink.c
@@ -789,9 +789,6 @@ static void unsuspend(struct userdata *u) {
PA_IDXSET_FOREACH(o, u->outputs, idx)
output_enable(o);
- if (!u->time_event && u->adjust_time > 0)
- u->time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + u->adjust_time, time_callback, u);
-
pa_log_info("Resumed successfully...");
}
@@ -823,6 +820,13 @@ static int sink_set_state_in_main_thread_cb(pa_sink *sink, pa_sink_state_t state
if (u->sink->state == PA_SINK_SUSPENDED)
unsuspend(u);
+ /* The first smoother update should be done early, otherwise the smoother will
+ * not be aware of the slave sink latencies and report far too small values.
+ * This is especially important if after an unsuspend the sink runs on a different
+ * latency than before. */
+ if (state == PA_SINK_RUNNING && !u->time_event && u->adjust_time > 0)
+ u->time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + pa_sink_get_requested_latency(u->sink), time_callback, u);
+
break;
case PA_SINK_UNLINKED: