From 9697b67802ef15477174eacb06c5fd30de01cc2d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 24 Oct 2024 10:55:50 +0200 Subject: [PATCH] filter-chain: first create instances and then link port First make instances of all the plugins and then try to link them up. Otherwise, depending on the order the plugins are defined in the config, a link will try to create port data and set it on the instance, which is still NULL and we crash. --- src/modules/module-filter-chain.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/modules/module-filter-chain.c b/src/modules/module-filter-chain.c index 6d3111933..7376b59da 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -2348,19 +2348,12 @@ static int graph_instantiate(struct graph *graph) graph->instantiated = true; + /* first make instances */ spa_list_for_each(node, &graph->node_list, link) { - node_cleanup(node); desc = node->desc; d = desc->desc; - if (d->flags & FC_DESCRIPTOR_SUPPORTS_NULL_DATA) { - sd = dd = NULL; - } - else { - sd = impl->silence_data; - dd = impl->discard_data; - } for (i = 0; i < node->n_hndl; i++) { pw_log_info("instantiate %s %d rate:%lu", d->name, i, impl->rate); @@ -2370,6 +2363,21 @@ static int graph_instantiate(struct graph *graph) res = -errno; goto error; } + } + } + + /* then link ports and activate */ + spa_list_for_each(node, &graph->node_list, link) { + desc = node->desc; + d = desc->desc; + if (d->flags & FC_DESCRIPTOR_SUPPORTS_NULL_DATA) { + sd = dd = NULL; + } + else { + sd = impl->silence_data; + dd = impl->discard_data; + } + for (i = 0; i < node->n_hndl; i++) { for (j = 0; j < desc->n_input; j++) { port = &node->input_port[j]; d->connect_port(node->hndl[i], port->p, sd);