impl-node: avoid scheduling the node before added

The Start command might be async and we should not schedule the node
until the reply has arrived and we have actually added the node to
the graph.

Otherwise it is possible that the node is scheduled before it could
complete the start command. This could be a problem for adapter because
it does negotiation and so on in the Start call.

See #2677
This commit is contained in:
Wim Taymans 2022-09-08 10:31:46 +02:00
parent 27211856eb
commit ff84acdf3d
2 changed files with 13 additions and 0 deletions

View file

@ -92,6 +92,8 @@ static void add_node(struct pw_impl_node *this, struct pw_impl_node *driver)
struct pw_node_activation_state *dstate, *nstate;
struct pw_node_target *t;
this->rt.added = true;
if (this->exported)
return;
@ -128,6 +130,8 @@ static void remove_node(struct pw_impl_node *this)
struct pw_node_activation_state *dstate, *nstate;
struct pw_node_target *t;
this->rt.added = false;
if (this->exported)
return;
@ -1078,6 +1082,14 @@ static inline int process_node(void *data)
a->status = PW_NODE_ACTIVATION_AWAKE;
a->awake_time = SPA_TIMESPEC_TO_NSEC(&ts);
if (!this->rt.added) {
/* FIXME we should try to avoid this by only activating the input
* links after we add the node to the graph. Otherwise there is
* no problem because the target (driver and peers) are not yet
* waiting for our activation */
pw_log_debug("%p: scheduling non-active node", this);
return -EIO;
}
pw_log_trace_fp("%p: process %"PRIu64, this, a->awake_time);
/* when transport sync is not supported, just clear the flag */

View file

@ -750,6 +750,7 @@ struct pw_impl_node {
struct spa_list driver_link; /* our link in driver */
struct ratelimit rate_limit;
unsigned int added:1; /**< the node was add to graph */
} rt;
struct spa_fraction current_rate;
uint64_t current_quantum;