[vlc-devel] [PATCH v2 22/26] text renderer: use a typed close callback in the operations structure
Steve Lhomme
robux4 at ycbcr.xyz
Fri Oct 9 15:04:18 CEST 2020
---
modules/text_renderer/freetype/freetype.c | 11 +++++------
modules/text_renderer/nsspeechsynthesizer.m | 9 ++++-----
modules/text_renderer/sapi.cpp | 8 ++++----
modules/text_renderer/svg.c | 9 ++++-----
4 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c
index fe78056212d..a866b99d725 100644
--- a/modules/text_renderer/freetype/freetype.c
+++ b/modules/text_renderer/freetype/freetype.c
@@ -54,7 +54,7 @@
* Module descriptor
*****************************************************************************/
static int Create ( vlc_object_t * );
-static void Destroy( vlc_object_t * );
+static void Destroy( filter_t * );
#define FONT_TEXT N_("Font")
#define MONOSPACE_FONT_TEXT N_("Monospace Font")
@@ -206,7 +206,7 @@ vlc_module_begin ()
set_capability( "text renderer", 100 )
add_shortcut( "text" )
- set_callbacks( Create, Destroy )
+ set_callback( Create )
vlc_module_end ()
/* */
@@ -1161,7 +1161,7 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region_out,
static const struct vlc_filter_operations filter_ops =
{
- .render = Render,
+ .render = Render, .close = Destroy,
};
/*****************************************************************************
@@ -1246,7 +1246,7 @@ static int Create( vlc_object_t *p_this )
return VLC_SUCCESS;
error:
- Destroy( VLC_OBJECT(p_filter) );
+ Destroy( p_filter );
return VLC_EGENERIC;
}
@@ -1255,9 +1255,8 @@ error:
*****************************************************************************
* Clean up all data and library connections
*****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
#ifdef DEBUG_PLATFORM_FONTS
diff --git a/modules/text_renderer/nsspeechsynthesizer.m b/modules/text_renderer/nsspeechsynthesizer.m
index 5e6774f09af..f3b7d7e1512 100644
--- a/modules/text_renderer/nsspeechsynthesizer.m
+++ b/modules/text_renderer/nsspeechsynthesizer.m
@@ -36,7 +36,7 @@
#import <Cocoa/Cocoa.h>
static int Create (vlc_object_t *);
-static void Destroy(vlc_object_t *);
+static void Destroy(filter_t *);
static int RenderText(filter_t *,
subpicture_region_t *,
subpicture_region_t *,
@@ -48,7 +48,7 @@ set_category(CAT_VIDEO)
set_subcategory(SUBCAT_VIDEO_SUBPIC)
set_capability("text renderer", 0)
-set_callbacks(Create, Destroy)
+set_callback(Create)
vlc_module_end ()
typedef struct filter_sys_t
@@ -59,7 +59,7 @@ typedef struct filter_sys_t
} filter_sys_t;
static const struct vlc_filter_operations filter_ops = {
- .render = RenderText,
+ .render = RenderText, .close = Destroy,
};
static int Create (vlc_object_t *p_this)
@@ -79,9 +79,8 @@ static int Create (vlc_object_t *p_this)
return VLC_SUCCESS;
}
-static void Destroy(vlc_object_t *p_this)
+static void Destroy(filter_t *p_filter)
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
[p_sys->speechSynthesizer stopSpeaking];
diff --git a/modules/text_renderer/sapi.cpp b/modules/text_renderer/sapi.cpp
index ad5109ef05c..f12961ecef5 100644
--- a/modules/text_renderer/sapi.cpp
+++ b/modules/text_renderer/sapi.cpp
@@ -45,7 +45,7 @@
#include <sphelper.h>
static int Create (vlc_object_t *);
-static void Destroy(vlc_object_t *);
+static void Destroy(filter_t *);
static int RenderText(filter_t *,
subpicture_region_t *,
subpicture_region_t *,
@@ -58,7 +58,7 @@ vlc_module_begin ()
set_subcategory(SUBCAT_VIDEO_SUBPIC)
set_capability("text renderer", 0)
- set_callbacks(Create, Destroy)
+ set_callback(Create)
add_integer("sapi-voice", -1, "Voice Index", "Voice index", false)
vlc_module_end ()
@@ -98,6 +98,7 @@ static const struct FilterOperationInitializer {
FilterOperationInitializer()
{
ops.render = RenderText;
+ ops.close = Destroy;
};
} filter_ops;
@@ -175,9 +176,8 @@ error:
return VLC_EGENERIC;
}
-static void Destroy(vlc_object_t *p_this)
+static void Destroy(filter_t *p_filter)
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = reinterpret_cast<filter_sys_t *>( p_filter->p_sys );
if (p_sys->cpVoice)
diff --git a/modules/text_renderer/svg.c b/modules/text_renderer/svg.c
index 5e710d15eec..fbb55f6beb0 100644
--- a/modules/text_renderer/svg.c
+++ b/modules/text_renderer/svg.c
@@ -48,7 +48,7 @@
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
-static void Destroy ( vlc_object_t * );
+static void Destroy ( filter_t * );
static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
subpicture_region_t *p_region_in,
const vlc_fourcc_t * );
@@ -76,7 +76,7 @@ vlc_module_begin ()
set_capability( "text renderer", 99 )
add_shortcut( "svg" )
add_string( "svg-template-file", "", TEMPLATE_TEXT, TEMPLATE_LONGTEXT, true )
- set_callbacks( Create, Destroy )
+ set_callback( Create )
vlc_module_end ()
static void svg_RescaletoFit ( filter_t *, int *width, int *height, float * );
@@ -170,7 +170,7 @@ static char *svg_GetDocument( filter_t *p_filter, int i_width, int i_height, con
}
static const struct vlc_filter_operations filter_ops = {
- .render = RenderText,
+ .render = RenderText, .close = Destroy,
};
/*****************************************************************************
@@ -203,9 +203,8 @@ static int Create( vlc_object_t *p_this )
*****************************************************************************
* Clean up all data and library connections
*****************************************************************************/
-static void Destroy( vlc_object_t *p_this )
+static void Destroy( filter_t *p_filter )
{
- filter_t *p_filter = ( filter_t * )p_this;
filter_sys_t *p_sys = p_filter->p_sys;
#if (GLIB_MAJOR_VERSION < 2 || GLIB_MINOR_VERSION < 36)
rsvg_term();
--
2.26.2
More information about the vlc-devel
mailing list