impl-link: only make passive links with suspendable peers

Only make a passive link when one of the peers is passive and the other
one can be suspended or when both are explicitly passive.

This avoid making passive links between a sink/source pair.

It also avoid making passive links between two streams if they are not
explicitly marked as passive.

It does allow making passive links between a passive stream and a
sink/source or between two passive streams.
This commit is contained in:
Wim Taymans 2023-03-28 18:10:20 +02:00
parent c84ef9e29a
commit f28c30d526
3 changed files with 11 additions and 1 deletions

View file

@ -1203,7 +1203,10 @@ struct pw_impl_link *pw_context_create_link(struct pw_context *context,
/* passive means that this link does not make the nodes active */
str = pw_properties_get(properties, PW_KEY_LINK_PASSIVE);
this->passive = str ? spa_atob(str) : output->passive | input->passive;
this->passive = str ? spa_atob(str) :
(output->passive && input_node->can_suspend) ||
(input->passive && output_node->can_suspend) ||
(input->passive && output->passive);
if (this->passive && str == NULL)
pw_properties_set(properties, PW_KEY_LINK_PASSIVE, "true");

View file

@ -956,6 +956,12 @@ static void check_properties(struct pw_impl_node *node)
recalc_reason = "link group changed";
}
if ((str = pw_properties_get(node->properties, PW_KEY_MEDIA_CLASS)) != NULL &&
(strstr(str, "/Sink") != NULL || strstr(str, "/Source") != NULL)) {
node->can_suspend = true;
} else {
node->can_suspend = false;
}
if ((str = pw_properties_get(node->properties, PW_KEY_NODE_PASSIVE)) == NULL)
str = "false";
if (spa_streq(str, "out"))

View file

@ -705,6 +705,7 @@ struct pw_impl_node {
unsigned int forced_rate:1;
unsigned int trigger:1; /**< has the TRIGGER property and needs an extra
* trigger to start processing. */
unsigned int can_suspend:1;
uint32_t port_user_data_size; /**< extra size for port user data */