port: debug passive modes better

This commit is contained in:
Wim Taymans 2026-04-08 13:21:24 +02:00
parent 7012594926
commit 446e36807f
3 changed files with 31 additions and 9 deletions

View file

@ -194,12 +194,16 @@ static void make_runnable(struct pw_context *context, struct pw_impl_node *node)
*/ */
static inline bool runnable_pair(struct pw_impl_port *a, struct pw_impl_port *b) static inline bool runnable_pair(struct pw_impl_port *a, struct pw_impl_port *b)
{ {
bool res = false;
if (a->passive_mode == PASSIVE_MODE_FALSE) if (a->passive_mode == PASSIVE_MODE_FALSE)
return true; res = true;
if (a->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND && if (a->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND &&
b->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND) b->passive_mode == PASSIVE_MODE_FOLLOW_SUSPEND)
return true; res = true;
return false; pw_log_trace(" port %p <-> %p: %s <> %s -> %d", a, b,
passive_mode_to_string(a->passive_mode),
passive_mode_to_string(b->passive_mode), res);
return res;
} }
static void check_runnable(struct pw_context *context, struct pw_impl_node *node) static void check_runnable(struct pw_context *context, struct pw_impl_node *node)
{ {
@ -218,8 +222,8 @@ static void check_runnable(struct pw_context *context, struct pw_impl_node *node
n = l->input->node; n = l->input->node;
/* the peer needs to be active and we are linked to it /* the peer needs to be active and we are linked to it
* with a non-passive link */ * with a non-passive link */
pw_log_trace(" out-port %p: link %p passive:%d prepared:%d active:%d", p, pw_log_trace(" out-port %p: link %p prepared:%d active:%d", p,
l, p->passive_mode, l->prepared, n->active); l, l->prepared, n->active);
if (!n->active || !runnable_pair(p, l->input)) if (!n->active || !runnable_pair(p, l->input))
continue; continue;
/* explicitly prepare the link in case it was suspended */ /* explicitly prepare the link in case it was suspended */
@ -233,8 +237,8 @@ static void check_runnable(struct pw_context *context, struct pw_impl_node *node
spa_list_for_each(p, &node->input_ports, link) { spa_list_for_each(p, &node->input_ports, link) {
spa_list_for_each(l, &p->links, input_link) { spa_list_for_each(l, &p->links, input_link) {
n = l->output->node; n = l->output->node;
pw_log_trace(" in-port %p: link %p passive:%d prepared:%d active:%d", p, pw_log_trace(" in-port %p: link %p prepared:%d active:%d", p,
l, p->passive_mode, l->prepared, n->active); l, l->prepared, n->active);
if (!n->active || !runnable_pair(p, l->output)) if (!n->active || !runnable_pair(p, l->output))
continue; continue;
pw_impl_link_prepare(l); pw_impl_link_prepare(l);

View file

@ -1346,8 +1346,10 @@ static void check_properties(struct pw_impl_node *node)
recalc_reason = "force rate changed"; recalc_reason = "force rate changed";
} }
pw_log_debug("%p: driver:%d recalc:%s active:%d passive:%d:%d", node, node->driver, pw_log_debug("%p: driver:%d recalc:%s active:%d passive:%s:%s", node, node->driver,
recalc_reason, node->active, node->passive_mode[0], node->passive_mode[1]); recalc_reason, node->active,
passive_mode_to_string(node->passive_mode[0]),
passive_mode_to_string(node->passive_mode[1]));
if (recalc_reason != NULL && node->active) if (recalc_reason != NULL && node->active)
pw_context_recalc_graph(context, recalc_reason); pw_context_recalc_graph(context, recalc_reason);

View file

@ -989,6 +989,22 @@ struct pw_impl_port {
void *user_data; /**< extra user data */ void *user_data; /**< extra user data */
}; };
static inline const char* passive_mode_to_string(uint32_t passive_mode)
{
switch (passive_mode) {
case PASSIVE_MODE_FALSE:
return "false";
case PASSIVE_MODE_TRUE:
return "true";
case PASSIVE_MODE_FOLLOW:
return "follow";
case PASSIVE_MODE_FOLLOW_SUSPEND:
return "follow";
default:
return "unknown";
}
}
struct pw_control_link { struct pw_control_link {
struct spa_list out_link; struct spa_list out_link;
struct spa_list in_link; struct spa_list in_link;