impl-node: improve suspend

Make sure we can only suspend when the node is (going to) IDLE. We don't
really want to allow applications to suspend a node that is running or
starting up.

This might fix a race when a node is suspended at the same time it is
started and cause silence. It also fixes the issue of total silence when
doing "pactl suspend <node> 1" on a running node.

See #3378
This commit is contained in:
Wim Taymans 2023-08-24 09:50:28 +02:00
parent 6ad0eb533d
commit 3b052eaa99

View file

@ -591,6 +591,7 @@ static int node_send_command(void *object, const struct spa_command *command)
{
struct resource_data *data = object;
struct pw_impl_node *node = data->node;
struct impl *impl = SPA_CONTAINER_OF(node, struct impl, this);
uint32_t id = SPA_NODE_COMMAND_ID(command);
pw_log_debug("%p: got command %d (%s)", node, id,
@ -598,7 +599,9 @@ static int node_send_command(void *object, const struct spa_command *command)
switch (id) {
case SPA_NODE_COMMAND_Suspend:
suspend_node(node);
if (node->info.state == PW_NODE_STATE_ERROR ||
impl->pending_state == PW_NODE_STATE_IDLE)
suspend_node(node);
break;
default:
spa_node_send_command(node->node, command);