[PATCH] avfilter/af_lv2: call lilv_instance_activate before lilv_instance_run
Why: the change is done to comply with lilv expectations of hosts. Added call lilv_instance_activate in the config_output function to abide by lilv documentation that states it must be called before lilv_instance_run: "This MUST be called before calling lilv_instance_run()" - documentation source (https://github.com/lv2/lilv/blob/main/include/lilv/lilv.h) Added call lilv_instance_deactivate in the uninit function to abide by lv2 documentation: "If a host calls activate(), it MUST call deactivate() at some point in the future" - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h) Added instance_activated integer to LV2Context struct to track if instance was activated and only do lilv_instance_deactivate if was activated to abide by lv2 documentation: "Hosts MUST NOT call deactivate() unless activate() was previously called." - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h) Regarding the patcheck warning (possibly constant :instance_activated): This is a false positive since the struct member is zero-initialized. Fixes: trac issue #11661 (https://trac.ffmpeg.org/ticket/11661) Reported-by: Dave Flater Signed-off-by: Karl Mogensen <karlmogensen0@gmail.com> --- libavfilter/af_lv2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c index e7f3f9c588..df935601d4 100644 --- a/libavfilter/af_lv2.c +++ b/libavfilter/af_lv2.c @@ -74,6 +74,7 @@ typedef struct LV2Context { float *controls; LilvInstance *instance; + int instance_activated; LilvNode *atom_AtomPort; LilvNode *atom_Sequence; @@ -387,6 +388,9 @@ static int config_output(AVFilterLink *outlink) inlink->min_samples = inlink->max_samples = 4096; } + lilv_instance_activate(s->instance); + s->instance_activated = 1; + return 0; } @@ -574,6 +578,8 @@ static av_cold void uninit(AVFilterContext *ctx) lilv_node_free(s->lv2_OutputPort); lilv_node_free(s->lv2_InputPort); uri_table_destroy(&s->uri_table); + if (s->instance_activated) + lilv_instance_deactivate(s->instance); lilv_instance_free(s->instance); lilv_world_free(s->world); av_freep(&s->mins); -- 2.52.0
On Thu, Feb 26, 2026 at 02:55:58PM +0100, Karl Mogensen via ffmpeg-devel wrote:
Why: the change is done to comply with lilv expectations of hosts.
Added call lilv_instance_activate in the config_output function to abide by lilv documentation that states it must be called before lilv_instance_run: "This MUST be called before calling lilv_instance_run()" - documentation source (https://github.com/lv2/lilv/blob/main/include/lilv/lilv.h)
Added call lilv_instance_deactivate in the uninit function to abide by lv2 documentation: "If a host calls activate(), it MUST call deactivate() at some point in the future" - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)
Added instance_activated integer to LV2Context struct to track if instance was activated and only do lilv_instance_deactivate if was activated to abide by lv2 documentation: "Hosts MUST NOT call deactivate() unless activate() was previously called." - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)
Regarding the patcheck warning (possibly constant :instance_activated): This is a false positive since the struct member is zero-initialized.
Fixes: trac issue #11661 (https://trac.ffmpeg.org/ticket/11661) Reported-by: Dave Flater Signed-off-by: Karl Mogensen <karlmogensen0@gmail.com> --- libavfilter/af_lv2.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c index e7f3f9c588..df935601d4 100644 --- a/libavfilter/af_lv2.c +++ b/libavfilter/af_lv2.c @@ -74,6 +74,7 @@ typedef struct LV2Context { float *controls;
LilvInstance *instance; + int instance_activated;
LilvNode *atom_AtomPort; LilvNode *atom_Sequence; @@ -387,6 +388,9 @@ static int config_output(AVFilterLink *outlink) inlink->min_samples = inlink->max_samples = 4096; }
+ lilv_instance_activate(s->instance); + s->instance_activated = 1; + return 0; }
@@ -574,6 +578,8 @@ static av_cold void uninit(AVFilterContext *ctx) lilv_node_free(s->lv2_OutputPort); lilv_node_free(s->lv2_InputPort); uri_table_destroy(&s->uri_table); + if (s->instance_activated) + lilv_instance_deactivate(s->instance);
shouldnt lilv_instance_deactivate() be called before the stuff above ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato
Thanks, yes you I think you are right - I will fix it and submit a v2 patch ________________________________ From: Michael Niedermayer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> Sent: Saturday, February 28, 2026 10:29 PM To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Cc: Michael Niedermayer <michael@niedermayer.cc> Subject: [FFmpeg-devel] Re: [PATCH] avfilter/af_lv2: call lilv_instance_activate before lilv_instance_run On Thu, Feb 26, 2026 at 02:55:58PM +0100, Karl Mogensen via ffmpeg-devel wrote:
Why: the change is done to comply with lilv expectations of hosts.
Added call lilv_instance_activate in the config_output function to abide by lilv documentation that states it must be called before lilv_instance_run: "This MUST be called before calling lilv_instance_run()" - documentation source (https://github.com/lv2/lilv/blob/main/include/lilv/lilv.h)
Added call lilv_instance_deactivate in the uninit function to abide by lv2 documentation: "If a host calls activate(), it MUST call deactivate() at some point in the future" - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)
Added instance_activated integer to LV2Context struct to track if instance was activated and only do lilv_instance_deactivate if was activated to abide by lv2 documentation: "Hosts MUST NOT call deactivate() unless activate() was previously called." - documentation source (https://gitlab.com/lv2/lv2/-/blob/main/include/lv2/core/lv2.h)
Regarding the patcheck warning (possibly constant :instance_activated): This is a false positive since the struct member is zero-initialized.
Fixes: trac issue #11661 (https://trac.ffmpeg.org/ticket/11661) Reported-by: Dave Flater Signed-off-by: Karl Mogensen <karlmogensen0@gmail.com> --- libavfilter/af_lv2.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c index e7f3f9c588..df935601d4 100644 --- a/libavfilter/af_lv2.c +++ b/libavfilter/af_lv2.c @@ -74,6 +74,7 @@ typedef struct LV2Context { float *controls;
LilvInstance *instance; + int instance_activated;
LilvNode *atom_AtomPort; LilvNode *atom_Sequence; @@ -387,6 +388,9 @@ static int config_output(AVFilterLink *outlink) inlink->min_samples = inlink->max_samples = 4096; }
+ lilv_instance_activate(s->instance); + s->instance_activated = 1; + return 0; }
@@ -574,6 +578,8 @@ static av_cold void uninit(AVFilterContext *ctx) lilv_node_free(s->lv2_OutputPort); lilv_node_free(s->lv2_InputPort); uri_table_destroy(&s->uri_table); + if (s->instance_activated) + lilv_instance_deactivate(s->instance);
shouldnt lilv_instance_deactivate() be called before the stuff above ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato
participants (3)
-
Karl Mogensen -
karl mogensen -
Michael Niedermayer