From 0c3db348f07b0f6652034729ac0b4d5634bfc72a Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 29 Jun 2026 10:36:26 +0200 Subject: [PATCH] audioconvert: small cleanups Move the sync code to before it is used. We don't need to clear the graph setup state anymore in force mode, we did that before we did the sync. --- spa/plugins/audioconvert/audioconvert.c | 47 +++++++++++-------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/spa/plugins/audioconvert/audioconvert.c b/spa/plugins/audioconvert/audioconvert.c index 6bc538aa3..56d3ea9f5 100644 --- a/spa/plugins/audioconvert/audioconvert.c +++ b/spa/plugins/audioconvert/audioconvert.c @@ -1290,8 +1290,28 @@ static int ensure_tmp(struct impl *this) return 0; } +static int do_sync_filter_graph(struct spa_loop *loop, bool async, uint32_t seq, + const void *data, size_t size, void *user_data) +{ + struct impl *impl = user_data; + struct filter_graph *g; -static void sync_filter_graph(struct impl *impl); + impl->n_graph = 0; + spa_list_for_each(g, &impl->active_graphs, link) + if (g->setup && !g->removing) + impl->filter_graph[impl->n_graph++] = g; + + impl->recalc = true; + return 0; +} + +static void sync_filter_graph(struct impl *impl) +{ + if (impl->data_loop) + spa_loop_locked(impl->data_loop, do_sync_filter_graph, 0, NULL, 0, impl); + else + do_sync_filter_graph(NULL, false, 0, NULL, 0, impl); +} static int setup_filter_graphs(struct impl *impl, bool force) { @@ -1324,8 +1344,6 @@ static int setup_filter_graphs(struct impl *impl, bool force) spa_list_for_each_safe(g, t, &impl->active_graphs, link) { if (g->removing) continue; - if (force) - g->setup = false; if ((res = setup_filter_graph(impl, g, channels, position)) < 0) { g->removing = true; spa_log_warn(impl->log, "failed to activate graph %d: %s", g->order, @@ -1344,29 +1362,6 @@ static int setup_filter_graphs(struct impl *impl, bool force) return 0; } -static int do_sync_filter_graph(struct spa_loop *loop, bool async, uint32_t seq, - const void *data, size_t size, void *user_data) -{ - struct impl *impl = user_data; - struct filter_graph *g; - - impl->n_graph = 0; - spa_list_for_each(g, &impl->active_graphs, link) - if (g->setup && !g->removing) - impl->filter_graph[impl->n_graph++] = g; - - impl->recalc = true; - return 0; -} - -static void sync_filter_graph(struct impl *impl) -{ - if (impl->data_loop) - spa_loop_locked(impl->data_loop, do_sync_filter_graph, 0, NULL, 0, impl); - else - do_sync_filter_graph(NULL, false, 0, NULL, 0, impl); -} - static void clean_filter_handles(struct impl *impl, bool force) { struct filter_graph *g, *t;