[vlc-devel] [PATCH 6/7] filters: use macro to set the typed Open callback for SPU source filters
Steve Lhomme
robux4 at ycbcr.xyz
Mon Oct 12 15:59:14 CEST 2020
---
include/vlc_filter.h | 9 +++++++++
modules/spu/audiobargraph_v.c | 14 ++++++--------
modules/spu/dynamicoverlay/dynamicoverlay.c | 8 +++-----
modules/spu/logo.c | 20 +++++++++-----------
modules/spu/marq.c | 8 +++-----
modules/spu/mosaic.c | 8 +++-----
modules/spu/rss.c | 8 +++-----
7 files changed, 36 insertions(+), 39 deletions(-)
diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index 4517d28cb46..d9eb54e72e2 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -145,6 +145,7 @@ 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 *);
+typedef int (*vlc_video_sub_source_open)(filter_t *);
#define set_deinterlace_callback( activate ) \
@@ -188,6 +189,14 @@ typedef int (*vlc_video_sub_filter_open)(filter_t *);
} \
set_capability( "sub filter", 0 )
+#define set_callback_sub_source( activate, priority ) \
+ { \
+ vlc_video_sub_source_open open__ = activate; \
+ (void) open__; \
+ set_callback(activate) \
+ } \
+ set_capability( "sub source", priority )
+
/** 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/audiobargraph_v.c b/modules/spu/audiobargraph_v.c
index b563cbed8d2..89c44637039 100644
--- a/modules/spu/audiobargraph_v.c
+++ b/modules/spu/audiobargraph_v.c
@@ -65,7 +65,7 @@ static const char *const ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
-static int OpenSub (vlc_object_t *);
+static int OpenSub (filter_t *);
static int OpenVideo(filter_t *);
static void Close (filter_t *);
@@ -74,8 +74,7 @@ vlc_module_begin ()
set_category(CAT_VIDEO)
set_subcategory(SUBCAT_VIDEO_SUBPIC)
- set_capability("sub source", 0)
- set_callback(OpenSub)
+ set_callback_sub_source(OpenSub, 0)
set_description(N_("Audio Bar Graph Video sub source"))
set_shortname(N_("Audio Bar Graph Video"))
add_shortcut("audiobargraph_v")
@@ -497,9 +496,8 @@ static const struct vlc_filter_operations filter_video_ops = {
/**
* Common open function
*/
-static int OpenCommon(vlc_object_t *p_this, bool b_sub)
+static int OpenCommon(filter_t *p_filter, bool b_sub)
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
/* */
@@ -575,9 +573,9 @@ static int OpenCommon(vlc_object_t *p_this, bool b_sub)
/**
* Open the sub source
*/
-static int OpenSub(vlc_object_t *p_this)
+static int OpenSub(filter_t *p_filter)
{
- return OpenCommon(p_this, true);
+ return OpenCommon(p_filter, true);
}
/**
@@ -585,7 +583,7 @@ static int OpenSub(vlc_object_t *p_this)
*/
static int OpenVideo(filter_t *p_filter)
{
- return OpenCommon(VLC_OBJECT(p_filter), false);
+ return OpenCommon(p_filter, false);
}
/**
diff --git a/modules/spu/dynamicoverlay/dynamicoverlay.c b/modules/spu/dynamicoverlay/dynamicoverlay.c
index 3640ad06862..4dc34642a0a 100644
--- a/modules/spu/dynamicoverlay/dynamicoverlay.c
+++ b/modules/spu/dynamicoverlay/dynamicoverlay.c
@@ -44,7 +44,7 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int Create( vlc_object_t * );
+static int Create( filter_t * );
static void Destroy( filter_t * );
static subpicture_t *Filter( filter_t *, vlc_tick_t );
@@ -67,14 +67,13 @@ vlc_module_begin ()
set_shortname( N_("Overlay" ))
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
- set_capability( "sub source", 0 )
add_loadfile("overlay-input", NULL, INPUT_TEXT, INPUT_LONGTEXT)
/* Note: add_loadfile as O_WRONLY w/o O_CREAT, i.e. FIFO must exist */
add_loadfile("overlay-output", NULL, OUTPUT_TEXT, OUTPUT_LONGTEXT)
add_shortcut( "overlay" )
- set_callback( Create )
+ set_callback_sub_source( Create, 0 )
vlc_module_end ()
static const char *const ppsz_filter_options[] = {
@@ -90,9 +89,8 @@ static const struct vlc_filter_operations filter_ops = {
*****************************************************************************
* This function allocates and initializes a adjust vout method.
*****************************************************************************/
-static int Create( vlc_object_t *p_this )
+static int Create( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
/* Allocate structure */
diff --git a/modules/spu/logo.c b/modules/spu/logo.c
index 40e5e8b61ab..fc60a3bc932 100644
--- a/modules/spu/logo.c
+++ b/modules/spu/logo.c
@@ -79,7 +79,7 @@ static const char *const ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
-static int OpenSub ( vlc_object_t * );
+static int OpenSub ( filter_t * );
static int OpenVideo( filter_t * );
static void Close ( filter_t * );
@@ -87,8 +87,7 @@ vlc_module_begin ()
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
set_help(LOGO_HELP)
- set_capability( "sub source", 0 )
- set_callback( OpenSub )
+ set_callback_sub_source( OpenSub, 0 )
set_description( N_("Logo sub source") )
set_shortname( N_("Logo overlay") )
add_shortcut( "logo" )
@@ -183,7 +182,7 @@ static const char *const ppsz_filter_callbacks[] = {
NULL
};
-static int OpenCommon( vlc_object_t *, bool b_sub );
+static int OpenCommon( filter_t *, bool b_sub );
static subpicture_t *FilterSub( filter_t *, vlc_tick_t );
static picture_t *FilterVideo( filter_t *, picture_t * );
@@ -201,9 +200,9 @@ static logo_t *LogoListCurrent( logo_list_t *p_list );
/**
* Open the sub source
*/
-static int OpenSub( vlc_object_t *p_this )
+static int OpenSub( filter_t *p_filter )
{
- return OpenCommon( p_this, true );
+ return OpenCommon( p_filter, true );
}
/**
@@ -211,7 +210,7 @@ static int OpenSub( vlc_object_t *p_this )
*/
static int OpenVideo( filter_t *p_filter )
{
- return OpenCommon( VLC_OBJECT(p_filter), false );
+ return OpenCommon( p_filter, false );
}
static const struct vlc_filter_operations filter_sub_ops = {
@@ -227,9 +226,8 @@ static const struct vlc_filter_operations filter_video_ops = {
/**
* Common open function
*/
-static int OpenCommon( vlc_object_t *p_this, bool b_sub )
+static int OpenCommon( filter_t *p_filter, bool b_sub )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
char *psz_filename;
@@ -275,7 +273,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
return VLC_ENOMEM;
}
if( *psz_filename == '\0' )
- msg_Warn( p_this, "no logo file specified" );
+ msg_Warn( p_filter, "no logo file specified" );
p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
p_list->i_alpha = VLC_CLIP( p_list->i_alpha, 0, 255 );
@@ -292,7 +290,7 @@ static int OpenCommon( vlc_object_t *p_this, bool b_sub )
p_sys->i_pos = 0;
vlc_mutex_init( &p_sys->lock );
- LogoListLoad( p_this, p_list, psz_filename );
+ LogoListLoad( VLC_OBJECT(p_filter), p_list, psz_filename );
p_sys->b_spu_update = true;
p_sys->b_mouse_grab = false;
diff --git a/modules/spu/marq.c b/modules/spu/marq.c
index 1129877a727..95baafcc7a7 100644
--- a/modules/spu/marq.c
+++ b/modules/spu/marq.c
@@ -43,7 +43,7 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int CreateFilter ( vlc_object_t * );
+static int CreateFilter ( filter_t * );
static void DestroyFilter( filter_t * );
static subpicture_t *Filter( filter_t *, vlc_tick_t );
@@ -136,11 +136,10 @@ static const char *const ppsz_pos_descriptions[] =
* Module descriptor
*****************************************************************************/
vlc_module_begin ()
- set_capability( "sub source", 0 )
set_shortname( N_("Marquee" ))
set_description( N_("Marquee display") )
set_help(MARQUEE_HELP)
- set_callback( CreateFilter )
+ set_callback_sub_source( CreateFilter, 0 )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
add_string( CFG_PREFIX "marquee", "VLC", MSG_TEXT, MSG_LONGTEXT,
@@ -185,9 +184,8 @@ static const struct vlc_filter_operations filter_ops = {
/*****************************************************************************
* CreateFilter: allocates marquee video filter
*****************************************************************************/
-static int CreateFilter( vlc_object_t *p_this )
+static int CreateFilter( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
/* Allocate structure */
diff --git a/modules/spu/mosaic.c b/modules/spu/mosaic.c
index 3c9f0b85385..ef2b6a955e3 100644
--- a/modules/spu/mosaic.c
+++ b/modules/spu/mosaic.c
@@ -44,7 +44,7 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int CreateFilter ( vlc_object_t * );
+static int CreateFilter ( filter_t * );
static void DestroyFilter ( filter_t * );
static subpicture_t *Filter ( filter_t *, vlc_tick_t );
@@ -176,8 +176,7 @@ vlc_module_begin ()
set_shortname( N_("Mosaic") )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC)
- set_capability( "sub source", 0 )
- set_callback( CreateFilter )
+ set_callback_sub_source( CreateFilter, 0 )
add_integer_with_range( CFG_PREFIX "alpha", 255, 0, 255,
ALPHA_TEXT, ALPHA_LONGTEXT, false )
@@ -278,9 +277,8 @@ static const struct vlc_filter_operations filter_ops = {
/*****************************************************************************
* CreateFiler: allocate mosaic video filter
*****************************************************************************/
-static int CreateFilter( vlc_object_t *p_this )
+static int CreateFilter( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
char *psz_order, *_psz_order;
char *psz_offsets;
diff --git a/modules/spu/rss.c b/modules/spu/rss.c
index f5a91294980..7bd08325261 100644
--- a/modules/spu/rss.c
+++ b/modules/spu/rss.c
@@ -49,7 +49,7 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int CreateFilter ( vlc_object_t * );
+static int CreateFilter ( filter_t * );
static void DestroyFilter( filter_t * );
static subpicture_t *Filter( filter_t *, vlc_tick_t );
@@ -188,10 +188,9 @@ static const char *const ppsz_title_modes[] =
* Module descriptor
*****************************************************************************/
vlc_module_begin ()
- set_capability( "sub source", 1 )
set_shortname( N_("RSS / Atom") )
set_help(RSS_HELP)
- set_callback( CreateFilter )
+ set_callback_sub_source( CreateFilter, 1 )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
add_string( CFG_PREFIX "urls", NULL, MSG_TEXT, MSG_LONGTEXT, false )
@@ -247,9 +246,8 @@ static const struct vlc_filter_operations filter_ops = {
/*****************************************************************************
* CreateFilter: allocates RSS video filter
*****************************************************************************/
-static int CreateFilter( vlc_object_t *p_this )
+static int CreateFilter( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
char *psz_urls;
int i_ttl;
--
2.26.2
More information about the vlc-devel
mailing list