[vlc-devel] [PATCH] filter: move pf_get_attachments to owner

Alexandre Janniaux ajanni at videolabs.io
Mon Jul 13 10:53:14 CEST 2020


Attachments are not coming from the filter but from the pipeline and is
called by the filter implementation itself. Thus, this is defined by the
owner implementation and should not be in the operation callbacks.

It's particularily noticeable in the callsite given that the
get_attachments implementation is using owner.sys.
---
 include/vlc_filter.h                | 15 ++++++++-------
 src/video_output/vout_subpictures.c |  7 ++++---
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 49e97f79887..9574c318d98 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -58,6 +58,11 @@ typedef struct filter_owner_t
         const struct filter_video_callbacks *video;
         const struct filter_subpicture_callbacks *sub;
     };
+
+    /* Input attachments
+     * XXX use filter_GetInputAttachments */
+    int (*pf_get_attachments)( filter_t *, input_attachment_t ***, int * );
+
     void *sys;
 } filter_owner_t;
 
@@ -148,10 +153,6 @@ struct filter_t
                                const struct vlc_mouse_t *p_new );
     };
 
-    /* Input attachments
-     * XXX use filter_GetInputAttachments */
-    int (*pf_get_attachments)( filter_t *, input_attachment_t ***, int * );
-
     /** Private structure for the owner of the filter */
     filter_owner_t      owner;
 };
@@ -260,10 +261,10 @@ static inline int filter_GetInputAttachments( filter_t *p_filter,
                                               input_attachment_t ***ppp_attachment,
                                               int *pi_attachment )
 {
-    if( !p_filter->pf_get_attachments )
+    if( !p_filter->owner.pf_get_attachments )
         return VLC_EGENERIC;
-    return p_filter->pf_get_attachments( p_filter,
-                                         ppp_attachment, pi_attachment );
+    return p_filter->owner.pf_get_attachments( p_filter,
+                                               ppp_attachment, pi_attachment );
 }
 
 /**
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 5ab940c1da5..4eea545dd0a 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -251,8 +251,6 @@ static filter_t *SpuRenderCreateAndLoadText(spu_t *spu)
     if (!text)
         return NULL;
 
-    text->owner.sys = spu;
-
     es_format_Init(&text->fmt_in, VIDEO_ES, 0);
 
     es_format_Init(&text->fmt_out, VIDEO_ES, 0);
@@ -261,7 +259,10 @@ static filter_t *SpuRenderCreateAndLoadText(spu_t *spu)
     text->fmt_out.video.i_height         =
     text->fmt_out.video.i_visible_height = 32;
 
-    text->pf_get_attachments = spu_get_attachments;
+    text->owner = (const struct filter_owner_t) {
+        .pf_get_attachments = spu_get_attachments,
+        .sys = spu
+    };
 
     text->p_module = module_need_var(text, "text renderer", "text-renderer");
     if (!text->p_module)
-- 
2.27.0



More information about the vlc-devel mailing list