impl-node: suspend before clearing format

First suspend and then clean the format. Otherwise we might clear the
format while running and potentially crash.
This commit is contained in:
Wim Taymans 2023-08-28 10:04:17 +02:00
parent 26ecde20b9
commit 289661b663

View file

@ -445,6 +445,17 @@ static int suspend_node(struct pw_impl_node *this)
node_deactivate(this);
pw_log_debug("%p: suspend node driving:%d driver:%d added:%d", this,
this->driving, this->driver, this->added);
res = spa_node_send_command(this->node,
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Suspend));
if (res == -ENOTSUP)
res = spa_node_send_command(this->node,
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause));
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",
@ -461,17 +472,6 @@ static int suspend_node(struct pw_impl_node *this)
p->state = PW_IMPL_PORT_STATE_CONFIGURE;
}
pw_log_debug("%p: suspend node driving:%d driver:%d added:%d", this,
this->driving, this->driver, this->added);
res = spa_node_send_command(this->node,
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Suspend));
if (res == -ENOTSUP)
res = spa_node_send_command(this->node,
&SPA_NODE_COMMAND_INIT(SPA_NODE_COMMAND_Pause));
if (res < 0 && res != -EIO)
pw_log_warn("%p: suspend node error %s", this, spa_strerror(res));
node_update_state(this, PW_NODE_STATE_SUSPENDED, 0, NULL);
return res;