From 6503351a0de7d00d08cf4a0d21bb31ce15236884 Mon Sep 17 00:00:00 2001 From: David Svensson Fors Date: Fri, 1 Dec 2017 16:31:37 +0100 Subject: [PATCH] graph: don't let required number of ports become negative Add a check against letting the required number of ports become negative for a node. With certain timing between the main and data thread, this can otherwise happen. For nodes where links are unlinked and relinked, a negative number may mean that the scheduler skips the node and doesn't call process_output(). --- spa/include/spa/graph/graph.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spa/include/spa/graph/graph.h b/spa/include/spa/graph/graph.h index 30d8531ca..4338b1193 100644 --- a/spa/include/spa/graph/graph.h +++ b/spa/include/spa/graph/graph.h @@ -160,8 +160,10 @@ static inline void spa_graph_port_remove(struct spa_graph_port *port) { spa_debug("port %p remove", port); spa_list_remove(&port->link); - if (!(port->flags & SPA_PORT_INFO_FLAG_OPTIONAL)) + if (!(port->flags & SPA_PORT_INFO_FLAG_OPTIONAL) && + port->node->required[port->direction] > 0) { port->node->required[port->direction]--; + } } static inline void