diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 8bb477345..b4c4d3d97 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -554,23 +554,10 @@ static int suspend_node(struct pw_impl_node *this) if (res < 0 && res != -EIO) pw_log_warn("%p: suspend node error %s", this, spa_strerror(res)); - spa_list_for_each(p, &this->input_ports, link) { - 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, 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, 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->input_ports, link) + pw_impl_port_suspend(p); + spa_list_for_each(p, &this->output_ports, link) + pw_impl_port_suspend(p); node_update_state(this, PW_NODE_STATE_SUSPENDED, 0, NULL); diff --git a/src/pipewire/impl-port.c b/src/pipewire/impl-port.c index a93449297..0a7af2c93 100644 --- a/src/pipewire/impl-port.c +++ b/src/pipewire/impl-port.c @@ -1610,6 +1610,16 @@ void pw_impl_port_destroy(struct pw_impl_port *port) free(port); } +void pw_impl_port_suspend(struct pw_impl_port *port) +{ + int res; + if ((res = pw_impl_port_set_param(port, SPA_PARAM_Format, 0, NULL)) < 0) + pw_log_warn("%p: error unset format: %s", port, spa_strerror(res)); + /* force CONFIGURE in case of async, use update_state to + * notify links so they can cancel pending work */ + pw_impl_port_update_state(port, PW_IMPL_PORT_STATE_CONFIGURE, 0, NULL); +} + struct result_port_params_data { struct impl *impl; void *data; diff --git a/src/pipewire/private.h b/src/pipewire/private.h index fa562b320..556cb4702 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -1326,6 +1326,9 @@ void pw_impl_port_unlink(struct pw_impl_port *port); /** Destroy a port */ void pw_impl_port_destroy(struct pw_impl_port *port); +/** Suepend a port */ +void pw_impl_port_suspend(struct pw_impl_port *port); + /** Iterate the params of the given port. The callback should return * 1 to fetch the next item, 0 to stop iteration or <0 on error. * The function returns 0 on success or the error returned by the callback. */