From 0881d5b881b9f955498b18561aa6e50e234a6d8f Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 9 Mar 2021 15:48:47 +0100 Subject: [PATCH] context: restart graph recalculation when something changed When we were busy with the graph recalculation and something changed, restart the graph state change to get the new change applied. For example, when we start a node and it has a max-quantum set, we need to restart our calculation with the new quantum limits. --- src/pipewire/context.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pipewire/context.c b/src/pipewire/context.c index cd7898c97..e6382394e 100644 --- a/src/pipewire/context.c +++ b/src/pipewire/context.c @@ -65,7 +65,8 @@ struct impl { struct pw_context this; struct spa_handle *dbus_handle; - unsigned int recalc; + unsigned int recalc:1; + unsigned int recalc_pending:1; }; @@ -918,9 +919,12 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason) pw_log_info(NAME" %p: busy:%d reason:%s", context, impl->recalc, reason); - if (impl->recalc) + if (impl->recalc) { + impl->recalc_pending = true; return -EBUSY; + } +again: impl->recalc = true; /* start from all drivers and group all nodes that are linked @@ -1041,6 +1045,11 @@ int pw_context_recalc_graph(struct pw_context *context, const char *reason) ensure_state(n, running); } impl->recalc = false; + if (impl->recalc_pending) { + impl->recalc_pending = false; + goto again; + } + return 0; }