From fe417bd1237f26a070f1fc41c5899562c4c524e2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 7 Dec 2021 12:09:59 +0100 Subject: [PATCH] improve latency debug --- pipewire-jack/src/pipewire-jack.c | 7 ++++++- src/pipewire/impl-port.c | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pipewire-jack/src/pipewire-jack.c b/pipewire-jack/src/pipewire-jack.c index 7e44bb0c9..53fd4f7b3 100644 --- a/pipewire-jack/src/pipewire-jack.c +++ b/pipewire-jack/src/pipewire-jack.c @@ -4973,9 +4973,13 @@ SPA_EXPORT void jack_port_set_latency (jack_port_t *port, jack_nframes_t frames) { struct object *o = (struct object *) port; + struct client *c; jack_latency_range_t range = { frames, frames }; spa_return_if_fail(o != NULL); + c = o->client; + + pw_log_debug("%p: %s set latency %d", c, o->port.name, frames); if (o->port.flags & JackPortIsOutput) { jack_port_set_latency_range(port, JackCaptureLatency, &range); @@ -5013,7 +5017,8 @@ void jack_port_get_latency_range (jack_port_t *port, jack_latency_callback_mode_ range->max = (info->max_quantum * nframes) + info->max_rate + (info->max_ns * rate) / SPA_NSEC_PER_SEC; - pw_log_debug("%p: get %d latency range %d %d", o, mode, range->min, range->max); + pw_log_debug("%p: %s get %d latency range %d %d", c, o->port.name, + mode, range->min, range->max); } static int diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index b6287ceb9..4ce00dcf2 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -1314,10 +1314,13 @@ int pw_impl_port_recalc_latency(struct pw_impl_port *port) struct spa_pod *param; struct spa_pod_builder b = { 0 }; uint8_t buffer[1024]; + bool changed; if (port->destroying) return 0; + /* given an output port, we calculate the total latency to the sinks or the input + * latency. */ spa_latency_info_combine_start(&latency, SPA_DIRECTION_REVERSE(port->direction)); if (port->direction == PW_DIRECTION_OUTPUT) { @@ -1345,17 +1348,20 @@ int pw_impl_port_recalc_latency(struct pw_impl_port *port) current = &port->latency[latency.direction]; - if (spa_latency_info_compare(current, &latency) == 0) - return 0; + changed = spa_latency_info_compare(current, &latency) != 0; - *current = latency; - - pw_log_debug("port %d: set %s latency %f-%f %d-%d %"PRIu64"-%"PRIu64, - port->info.id, pw_direction_as_string(latency.direction), + pw_log_info("port %d: %s %s latency %f-%f %d-%d %"PRIu64"-%"PRIu64, + port->info.id, changed ? "set" : "keep", + pw_direction_as_string(latency.direction), latency.min_quantum, latency.max_quantum, latency.min_rate, latency.max_rate, latency.min_ns, latency.max_ns); + if (!changed) + return 0; + + *current = latency; + if (!port->have_latency_param) return 0;