impl-port: add port_suspend()

Move the logic to suspend a port to the port implementation. No
functional change with this.
This commit is contained in:
Wim Taymans 2026-06-01 10:21:42 +02:00
parent 54199d77c6
commit f22932580f
3 changed files with 17 additions and 17 deletions

View file

@ -554,23 +554,10 @@ static int suspend_node(struct pw_impl_node *this)
if (res < 0 && res != -EIO) if (res < 0 && res != -EIO)
pw_log_warn("%p: suspend node error %s", this, spa_strerror(res)); pw_log_warn("%p: suspend node error %s", this, spa_strerror(res));
spa_list_for_each(p, &this->input_ports, link) { spa_list_for_each(p, &this->input_ports, link)
if ((res = pw_impl_port_set_param(p, SPA_PARAM_Format, 0, NULL)) < 0) pw_impl_port_suspend(p);
pw_log_warn("%p: error unset format input: %s", spa_list_for_each(p, &this->output_ports, link)
this, spa_strerror(res)); pw_impl_port_suspend(p);
/* 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);
}
node_update_state(this, PW_NODE_STATE_SUSPENDED, 0, NULL); node_update_state(this, PW_NODE_STATE_SUSPENDED, 0, NULL);

View file

@ -1610,6 +1610,16 @@ void pw_impl_port_destroy(struct pw_impl_port *port)
free(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 result_port_params_data {
struct impl *impl; struct impl *impl;
void *data; void *data;

View file

@ -1326,6 +1326,9 @@ void pw_impl_port_unlink(struct pw_impl_port *port);
/** Destroy a port */ /** Destroy a port */
void pw_impl_port_destroy(struct pw_impl_port *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 /** 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. * 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. */ * The function returns 0 on success or the error returned by the callback. */