[vlc-devel] [PATCH] filter: add a pf_close callback
Alexandre Janniaux
ajanni at videolabs.io
Fri Jul 17 10:30:56 CEST 2020
Having a pf_close callback associated to the object instead of the
module allows a filter to wrap any other filter transparently.
In particular, this is a central piece in order to expose other
capability kind of filter as a filter_t video filter using a wrapping
filter_t video filter implementation.
---
include/vlc_filter.h | 4 ++++
src/misc/filter.c | 4 ++++
src/misc/filter_chain.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 9574c318d98..3e52988e459 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -153,6 +153,10 @@ struct filter_t
const struct vlc_mouse_t *p_new );
};
+ /* Callback triggered when the filter is to be destroyed.
+ * This can be used in place of the module "close" callback. */
+ void (*pf_close)( filter_t * );
+
/** Private structure for the owner of the filter */
filter_owner_t owner;
};
diff --git a/src/misc/filter.c b/src/misc/filter.c
index e8c1cae82eb..c3f2aa9525c 100644
--- a/src/misc/filter.c
+++ b/src/misc/filter.c
@@ -121,6 +121,7 @@ vlc_blender_t *filter_NewBlend( vlc_object_t *p_this,
/* The blend module will be loaded when needed with the real
* input format */
p_blend->p_module = NULL;
+ p_blend->pf_close = NULL;
return p_blend;
}
@@ -170,6 +171,9 @@ int filter_Blend( vlc_blender_t *p_blend,
void filter_DeleteBlend( vlc_blender_t *p_blend )
{
+ if( p_blend->pf_close )
+ p_blend->pf_close( p_blend );
+
if( p_blend->p_module )
module_unneed( p_blend, p_blend->p_module );
diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 7b1a0ff63bf..a37f29e347b 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -211,6 +211,7 @@ static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
return NULL;
filter_t *filter = &chained->filter;
+ filter->pf_close = NULL;
const es_format_t *fmt_in;
vlc_video_context *vctx_in;
@@ -328,6 +329,9 @@ void filter_chain_DeleteFilter( filter_chain_t *chain, filter_t *filter )
chain->last = chained->prev;
}
+ if( filter->pf_close )
+ filter->pf_close( filter );
+
module_unneed( filter, filter->p_module );
msg_Dbg( chain->obj, "Filter %p removed from chain", (void *)filter );
--
2.27.0
More information about the vlc-devel
mailing list