From 42b994204df3212ee55f4aff472fc6cc39fe6abd 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 9e8aeda9b..268ef6bae 100644 --- a/src/modules/module-filter-chain.c +++ b/src/modules/module-filter-chain.c @@ -2433,19 +2433,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 %s[%d] rate:%lu", d->name, node->name, i, impl->rate); @@ -2455,6 +2448,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);