From 289661b663a76d1e85b20fc41f7167bcd112f7f4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 28 Aug 2023 10:04:17 +0200 Subject: [PATCH] impl-node: suspend before clearing format First suspend and then clean the format. Otherwise we might clear the format while running and potentially crash. --- src/pipewire/impl-node.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index ff9effedc..abfdd410f 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -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;