impl-node: use port_update_state() in suspend_node

Instead of just setting the port state directly, go through the
port_update_state() function. This will make suspend_node() also
emit the port state change event to the links. This then causes
the link to reset to INIT, which cancels pending complete_ready work
items and prevents them from changing the port to READY without a
valid format.

One possible situation where this could happen is when a suspend
happens while the port was waiting for a set_param(Format) reply from
the client-node.

See #3547
This commit is contained in:
Wim Taymans 2026-05-25 13:15:12 +02:00
parent df32ab9844
commit 12ca6f16d2

View file

@ -558,16 +558,18 @@ static int suspend_node(struct pw_impl_node *this)
if ((res = pw_impl_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0)
pw_log_warn("%p: error unset format input: %s",
this, spa_strerror(res));
/* force CONFIGURE in case of async */
p->state = PW_IMPL_PORT_STATE_CONFIGURE;
/* force CONFIGURE in case of async, use update_state to
* notify links so they can cancel pending work */
pw_impl_port_update_state(p, PW_IMPL_PORT_STATE_CONFIGURE, 0, NULL);
}
spa_list_for_each(p, &this->output_ports, link) {
if ((res = pw_impl_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0)
pw_log_warn("%p: error unset format output: %s",
this, spa_strerror(res));
/* force CONFIGURE in case of async */
p->state = PW_IMPL_PORT_STATE_CONFIGURE;
/* force CONFIGURE in case of async, use update_state to
* notify links so they can cancel pending work */
pw_impl_port_update_state(p, PW_IMPL_PORT_STATE_CONFIGURE, 0, NULL);
}
node_update_state(this, PW_NODE_STATE_SUSPENDED, 0, NULL);