From 3738c3fc3842c7a28e1082741f5d9dd528913a4d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 20 Dec 2025 18:02:36 +0100 Subject: [PATCH] tools: only print latency when we print the port Move the latency print code after where we print the port. That way we only get the latency when we first print the port. Avoid -lt from printing latencies for ports without a link. --- src/tools/pw-link.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/tools/pw-link.c b/src/tools/pw-link.c index 1853783ca..e33ceda7f 100644 --- a/src/tools/pw-link.c +++ b/src/tools/pw-link.c @@ -314,6 +314,24 @@ static char *port_alias(char *buffer, int size, struct object *n, struct object return buffer; } +static void print_port_latency(struct data *data, const char *prefix, + struct object *p, enum spa_direction direction) +{ + const char *state; + struct spa_latency_info *info = &p->latency[direction]; + + if (p->state == STATE_NONE || p->state == STATE_CHANGED) + state = p->latency_changed[direction] ? "*" : "="; + else + state = state_name(data, p); + + printf("%s%s %s latency: { quantum=[ %f %f ], rate=[ %d %d ], ns=[ %"PRIi64" %"PRIi64" ] }\n", + state, prefix, direction == SPA_DIRECTION_INPUT ? "input ": "output", + info->min_quantum, info->max_quantum, + info->min_rate, info->max_rate, info->min_ns, info->max_ns); + p->latency_changed[direction] = false; +} + static void print_port(struct data *data, const char *prefix, const char *state, struct object *n, struct object *p, bool verbose) { @@ -338,6 +356,10 @@ static void print_port(struct data *data, const char *prefix, const char *state, if (buffer[0] != '\0') printf("%s %s%s%s\n", state, prefix2, prefix, buffer); } + if (data->opt_list & LIST_LATENCY) { + print_port_latency(data, "", p, SPA_DIRECTION_INPUT); + print_port_latency(data, "", p, SPA_DIRECTION_OUTPUT); + } } static void print_port_id(struct data *data, const char *prefix, uint32_t peer, struct object *l) @@ -350,24 +372,6 @@ static void print_port_id(struct data *data, const char *prefix, uint32_t peer, print_port(data, prefix, state_name(data, l), n, p, false); } -static void print_port_latency(struct data *data, const char *prefix, - struct object *p, enum spa_direction direction) -{ - const char *state; - struct spa_latency_info *info = &p->latency[direction]; - - if (p->state == STATE_NONE || p->state == STATE_CHANGED) - state = p->latency_changed[direction] ? "*" : "="; - else - state = state_name(data, p); - - printf("%s%s %s latency: { quantum=[ %f %f ], rate=[ %d %d ], ns=[ %"PRIi64" %"PRIi64" ] }\n", - state, prefix, direction == SPA_DIRECTION_INPUT ? "input ": "output", - info->min_quantum, info->max_quantum, - info->min_rate, info->max_rate, info->min_ns, info->max_ns); - p->latency_changed[direction] = false; -} - static void do_list_port_links(struct data *data, struct object *node, struct object *port) { struct object *o; @@ -462,10 +466,6 @@ static void do_list_ports(struct data *data, struct object *node, if (data->opt_list & LIST_PORTS) print_port(data, "", NULL, node, o, data->opt_verbose); - if (data->opt_list & LIST_LATENCY) { - print_port_latency(data, "", o, SPA_DIRECTION_INPUT); - print_port_latency(data, "", o, SPA_DIRECTION_OUTPUT); - } if (data->opt_list & LIST_LINKS) do_list_port_links(data, node, o); }