[vlc-commits] filters: use macro to set the typed Open callback for subtitle filters

Steve Lhomme git at videolan.org
Tue Oct 13 11:07:10 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct  9 11:29:20 2020 +0200| [f9ab141d20fe03fd06fbb8ab2f08849e9c35afe3] | committer: Steve Lhomme

filters: use macro to set the typed Open callback for subtitle filters

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f9ab141d20fe03fd06fbb8ab2f08849e9c35afe3
---

 include/vlc_filter.h    | 9 +++++++++
 modules/spu/subsdelay.c | 8 +++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 6b3c395d7d..4517d28cb4 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -144,6 +144,7 @@ typedef int (*vlc_open_deinterlace)(filter_t *);
 typedef int (*vlc_video_converter_open)(filter_t *);
 typedef int (*vlc_video_filter_open)(filter_t *);
 typedef int (*vlc_video_text_renderer_open)(filter_t *);
+typedef int (*vlc_video_sub_filter_open)(filter_t *);
 
 
 #define set_deinterlace_callback( activate )     \
@@ -179,6 +180,14 @@ typedef int (*vlc_video_text_renderer_open)(filter_t *);
     }                                                      \
     set_capability( "text renderer", priority )
 
+#define set_callback_sub_filter( activate )                \
+    {                                                      \
+        vlc_video_sub_filter_open open__ = activate;       \
+        (void) open__;                                     \
+        set_callback(activate)                             \
+    }                                                      \
+    set_capability( "sub filter", 0 )
+
 /** Structure describing a filter
  * @warning BIG FAT WARNING : the code relies on the first 4 members of
  * filter_t and decoder_t to be the same, so if you have anything to add,
diff --git a/modules/spu/subsdelay.c b/modules/spu/subsdelay.c
index 61a82158fe..0d191f6233 100644
--- a/modules/spu/subsdelay.c
+++ b/modules/spu/subsdelay.c
@@ -184,7 +184,7 @@ typedef struct
  * Filter functions
  *****************************************************************************/
 
-static int SubsdelayCreate( vlc_object_t * );
+static int SubsdelayCreate( filter_t * );
 
 static void SubsdelayDestroy( filter_t * );
 
@@ -265,8 +265,7 @@ vlc_module_begin()
         set_shortname( N_("Subsdelay") )
         set_description( N_("Subtitle delay") )
         set_help( SUBSDELAY_HELP )
-        set_capability( "sub filter", 0 )
-        set_callback( SubsdelayCreate )
+        set_callback_sub_filter( SubsdelayCreate )
         set_category( CAT_VIDEO )
         set_subcategory( SUBCAT_VIDEO_SUBPIC )
 
@@ -300,9 +299,8 @@ static const struct vlc_filter_operations filter_ops = {
 /*****************************************************************************
  * SubsdelayCreate: Create subsdelay filter
  *****************************************************************************/
-static int SubsdelayCreate( vlc_object_t *p_this )
+static int SubsdelayCreate( filter_t *p_filter )
 {
-    filter_t *p_filter = (filter_t *) p_this;
     filter_sys_t *p_sys;
 
     /* allocate structure */



More information about the vlc-commits mailing list