From 7e553339e4c295290f0d40613301553f94592e04 Mon Sep 17 00:00:00 2001 From: Marcus Weseloh Date: Sat, 6 Mar 2021 17:03:58 +0100 Subject: [PATCH] Don't add effect control nodes to global node list As effect control nodes are private to the effect and only ever accessed via the effect and port name, they don't need to be added to the global node list and can be cleaned up in the effect destructor. --- src/bindings/fluid_ladspa.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/bindings/fluid_ladspa.c b/src/bindings/fluid_ladspa.c index 581fd54c..2c66dc0f 100644 --- a/src/bindings/fluid_ladspa.c +++ b/src/bindings/fluid_ladspa.c @@ -1319,8 +1319,25 @@ new_fluid_ladspa_effect(fluid_ladspa_fx_t *fx, const char *lib_name, const char static void delete_fluid_ladspa_effect(fluid_ladspa_effect_t *effect) { + unsigned int i; + fluid_ladspa_node_t *node; + fluid_return_if_fail(effect != NULL); + /* Control nodes are created automatically when the effect is instantiated and + * are private to this effect, so we can safely remove them here. Nodes connected + * to audio ports might be connected to other effects as well, so we simply remove + * any pointers to them from the effect. */ + for(i = 0; i < effect->desc->PortCount; i++) + { + node = (fluid_ladspa_node_t *) effect->port_nodes[i]; + + if(node && node->type & FLUID_LADSPA_NODE_CONTROL) + { + delete_fluid_ladspa_node(node); + } + } + FLUID_FREE(effect->port_nodes); if(effect->handle != NULL && effect->desc != NULL && effect->desc->cleanup != NULL) @@ -1587,8 +1604,6 @@ static int create_control_port_nodes(fluid_ladspa_fx_t *fx, fluid_ladspa_effect_ return FLUID_FAILED; } - fx->nodes = fluid_list_append(fx->nodes, node); - node->effect_buffer[0] = get_default_port_value(effect, i, fx->sample_rate); dir = (LADSPA_IS_PORT_INPUT(port_flags)) ? FLUID_LADSPA_INPUT : FLUID_LADSPA_OUTPUT;