From 3b51dbba1cd16484d48dc620a77f4abef1cc15da Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 15 Nov 2024 12:21:49 +0100 Subject: [PATCH] filter-graph: improve output port number calculations When no output ports are given, use the number of graph outputs, which needs to take into account the number of times we duplicated the graph. --- spa/plugins/filter-graph/filter-graph.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spa/plugins/filter-graph/filter-graph.c b/spa/plugins/filter-graph/filter-graph.c index 00a261af1..75965ed47 100644 --- a/spa/plugins/filter-graph/filter-graph.c +++ b/spa/plugins/filter-graph/filter-graph.c @@ -1608,12 +1608,14 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_ if (impl->info.n_inputs == 0) impl->info.n_inputs = n_input; - if (impl->info.n_outputs == 0) - impl->info.n_outputs = n_output; /* compare to the requested number of inputs and duplicate the * graph n_hndl times when needed. */ n_hndl = impl->info.n_inputs / n_input; + + if (impl->info.n_outputs == 0) + impl->info.n_outputs = n_output * n_hndl; + if (n_hndl != impl->info.n_outputs / n_output) { spa_log_error(impl->log, "invalid ports. The input stream has %1$d ports and " "the filter has %2$d inputs. The output stream has %3$d ports " @@ -1638,6 +1640,9 @@ static int setup_graph(struct graph *graph, struct spa_json *inputs, struct spa_ "unconnected..", impl->info.n_inputs, n_input, impl->info.n_outputs, n_output); + + if (impl->info.n_outputs == 0) + impl->info.n_outputs = n_output * n_hndl; } spa_log_info(impl->log, "using %d instances %d %d", n_hndl, n_input, n_output);