[vlc-commits] [Git][videolan/vlc][master] 8 commits: module: use vlc_set_cb for the plugin callback

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Mar 3 14:35:28 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
87d64675 by Steve Lhomme at 2023-03-03T14:13:29+00:00
module: use vlc_set_cb for the plugin callback

If that structure changes, the core should also reflect that change.

vlc_entry__core is also defined that way in libvlc-module.c via
vlc_module_begin().

- - - - -
a8ad45a9 by Steve Lhomme at 2023-03-03T14:13:29+00:00
vlc_plugin: make vlc_plugin_cb public

This will avoid defining it in all test files. They all include vlc_plugin.h
because they need vlc_set_cb.

- - - - -
722c0fa2 by Steve Lhomme at 2023-03-03T14:13:29+00:00
plugins: rename __PLUGIN__ to VLC_DYNAMIC_PLUGIN

We should not use names stating with underscore for our internal code.
This is almost the same name used in the makefile for more coherence.

HAVE_DYNAMIC_PLUGINS already exists in the core. We keep a different
name to separate the 2 usages. For now they mean exactly the same thing.

- - - - -
6b64606f by Steve Lhomme at 2023-03-03T14:13:29+00:00
demux-run: use types and macros from vlc_plugin.h

- - - - -
a22746f3 by Steve Lhomme at 2023-03-03T14:13:29+00:00
tests: define vlc_static_modules consistently

- - - - -
26b9e636 by Steve Lhomme at 2023-03-03T14:13:29+00:00
test: move MODULE_NAME/MODULE_STRING declaration at the top

Put it before the vlc_plugin.h include like other test files.

- - - - -
41d6cb46 by Steve Lhomme at 2023-03-03T14:13:29+00:00
plugin: define MODULE_STRING as the string version of MODULE_NAME

If MODULE_STRING is not defined just use a default name.
If MODULE_NAME is not set either it's a dynamic plugin and the MODULE_STRING
should be set, or it's an internal test and we don't care about the name.

- - - - -
63357faa by Steve Lhomme at 2023-03-03T14:13:29+00:00
test: don't define MODULE_xxx without vlc_plugin.h

It's not used and confusing.

- - - - -


20 changed files:

- include/vlc_plugin.h
- modules/common.am
- modules/meson.build
- src/modules/modules.h
- src/vlc-plugin.pc.in
- test/iosvlc.m
- test/modules/lua/extension.c
- test/modules/misc/medialibrary.c
- test/modules/stream_out/transcode.c
- test/modules/stream_out/transcode.h
- test/modules/stream_out/transcode_scenarios.c
- test/src/input/decoder/input_decoder.c
- test/src/input/decoder/input_decoder_scenarios.c
- test/src/input/demux-run.c
- test/src/misc/image.c
- test/src/misc/image_cvpx.c
- test/src/video_output/opengl.c
- test/src/video_output/video_output.c
- test/src/video_output/video_output.h
- test/src/video_output/video_output_scenarios.c


Changes:

=====================================
include/vlc_plugin.h
=====================================
@@ -233,6 +233,8 @@ enum vlc_config_subcat
 /* I need to do _this_ to change « foo bar » to « module_foo_bar » ! */
 #define CONCATENATE( y, z ) CRUDE_HACK( y, z )
 #define CRUDE_HACK( y, z )  y##__##z
+#define STRINGIFY_NAME_( z ) #z
+#define STRINGIFY_NAME( z )   STRINGIFY_NAME_( z )
 
 #if defined(__cplusplus)
 #define EXTERN_SYMBOL extern "C"
@@ -240,9 +242,13 @@ enum vlc_config_subcat
 #define EXTERN_SYMBOL
 #endif
 
+#if !defined(MODULE_STRING) && defined(MODULE_NAME)
+# define MODULE_STRING  STRINGIFY_NAME(MODULE_NAME)
+#endif
+
 /* If the module is built-in, then we need to define foo_InitModule instead
  * of InitModule. Same for Activate- and DeactivateModule. */
-#ifdef __PLUGIN__
+#ifdef VLC_DYNAMIC_PLUGIN
 # define VLC_SYMBOL(symbol) symbol
 # define VLC_MODULE_NAME_HIDDEN_SYMBOL \
     EXTERN_SYMBOL const char vlc_module_name[] = MODULE_STRING;
@@ -252,7 +258,7 @@ enum vlc_config_subcat
 #endif
 
 #define CDECL_SYMBOL
-#if defined (__PLUGIN__)
+#if defined (VLC_DYNAMIC_PLUGIN)
 # if defined (_WIN32)
 #   define DLL_SYMBOL              __declspec(dllexport)
 #   undef CDECL_SYMBOL
@@ -270,6 +276,9 @@ struct vlc_param;
 
 EXTERN_SYMBOL typedef int (*vlc_set_cb) (void *, void *, int, ...);
 
+/** Plugin entry point prototype */
+typedef int (*vlc_plugin_cb) (vlc_set_cb, void *);
+
 #define vlc_plugin_set(...) vlc_set (opaque,   NULL, __VA_ARGS__)
 #define vlc_module_set(...) vlc_set (opaque, module, __VA_ARGS__)
 #define vlc_config_set(...) vlc_set (opaque, config, __VA_ARGS__)
@@ -404,7 +413,7 @@ VLC_METADATA_EXPORTS
 #define set_section( text, longtext ) \
     add_typedesc_inner( CONFIG_SECTION, text, longtext )
 
-#ifndef __PLUGIN__
+#ifndef VLC_DYNAMIC_PLUGIN
 #define add_category_hint(text, longtext) \
     add_typedesc_inner( CONFIG_HINT_CATEGORY, text, longtext )
 #endif
@@ -435,7 +444,7 @@ VLC_METADATA_EXPORTS
     add_string_inner(CONFIG_ITEM_MODULE_LIST, name, text, longtext, value) \
     vlc_config_set (VLC_CONFIG_CAPABILITY, VLC_CHECKED_TYPE(const char *, cap));
 
-#ifndef __PLUGIN__
+#ifndef VLC_DYNAMIC_PLUGIN
 #define add_module_cat(name, subcategory, value, text, longtext) \
     add_string_inner(CONFIG_ITEM_MODULE_CAT, name, text, longtext, value) \
     change_integer_range (subcategory /* gruik */, 0);


=====================================
modules/common.am
=====================================
@@ -20,7 +20,7 @@ MODULE_NAME = $$(p="$@"; p=$$(echo "$$p"|sed 's/lib//g'); p="$${p%_plugin*}"; p=
 
 AM_CPPFLAGS = -DMODULE_STRING=\"$(MODULE_STRING)\"
 if HAVE_DYNAMIC_PLUGINS
-AM_CPPFLAGS += -D__PLUGIN__
+AM_CPPFLAGS += -DVLC_DYNAMIC_PLUGIN
 else
 AM_CPPFLAGS += -DMODULE_NAME=$(MODULE_NAME)
 endif


=====================================
modules/meson.build
=====================================
@@ -282,7 +282,7 @@ foreach module : vlc_modules
 
     common_args = [
         '-DMODULE_STRING="@0@"'.format(module['name']),
-        '-D__PLUGIN__'
+        '-DVLC_DYNAMIC_PLUGIN'
     ]
 
     library(module['name'] + '_plugin',


=====================================
src/modules/modules.h
=====================================
@@ -24,6 +24,7 @@
 # define LIBVLC_MODULES_H 1
 
 # include <stdatomic.h>
+# include <vlc_plugin.h>
 
 struct vlc_param;
 
@@ -65,14 +66,11 @@ extern struct vlc_plugin_t *vlc_plugins;
 
 #define MODULE_SHORTCUT_MAX 20
 
-/** Plugin entry point prototype */
-typedef int (*vlc_plugin_cb) (int (*)(void *, void *, int, ...), void *);
-
 /** Plugin deactivation callback */
 typedef void (*vlc_deactivate_cb)(vlc_object_t*);
 
 /** Core module */
-int vlc_entry__core (int (*)(void *, void *, int, ...), void *);
+int vlc_entry__core (vlc_set_cb, void *);
 
 /**
  * Internal module descriptor


=====================================
src/vlc-plugin.pc.in
=====================================
@@ -13,7 +13,7 @@ Name: VLC plugin API
 Description: VLC media player plugin interface
 Version: @VERSION@
 Cflags: -I${includedir} -I${pkgincludedir}/plugins \
-	-D__PLUGIN__ \
+	-DVLC_DYNAMIC_PLUGIN \
 	-D_FILE_OFFSET_BITS=64 \
 	@DEFS_BIGENDIAN@
 Libs: -L${libdir} -lvlccore


=====================================
test/iosvlc.m
=====================================
@@ -25,6 +25,10 @@
 # include "config.h"
 #endif
 
+#define MODULE_NAME ios_interface
+#define MODULE_STRING "ios_interface"
+#undef VLC_DYNAMIC_PLUGINS
+
 #import <UIKit/UIKit.h>
 #include <vlc/vlc.h>
 
@@ -153,15 +157,12 @@ static int Open(vlc_object_t *obj)
     return VLC_SUCCESS;
 }
 
-#define MODULE_NAME ios_interface
-#define MODULE_STRING "ios_interface"
 vlc_module_begin()
     set_capability("interface", 0)
     set_callback(Open)
 vlc_module_end()
 
-/* Inject the glue interface as a static module */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
-__attribute__((visibility("default")))
-vlc_plugin_cb vlc_static_modules[] = { vlc_entry__ios_interface, NULL };
+VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
+    VLC_SYMBOL(vlc_entry),
+    NULL
+};


=====================================
test/modules/lua/extension.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_lua_extension
 #define MODULE_STRING "test_lua_extension"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
@@ -127,9 +127,6 @@ vlc_module_begin()
     set_capability("interface", 0)
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
 VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL


=====================================
test/modules/misc/medialibrary.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_misc_medialibrary
 #define MODULE_STRING "test_misc_medialibrary"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
@@ -92,9 +92,6 @@ vlc_module_begin()
     set_capability("interface", 0)
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
 VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL


=====================================
test/modules/stream_out/transcode.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_transcode_mock
 #define MODULE_STRING "test_transcode_mock"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 
 static const char dec_dev_arg[] = "--dec-dev=" MODULE_STRING;
 
@@ -395,9 +395,6 @@ vlc_module_begin()
 
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
 VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL


=====================================
test/modules/stream_out/transcode.h
=====================================
@@ -20,10 +20,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#define MODULE_NAME test_transcode_mock
-#define MODULE_STRING "test_transcode_mock"
-#undef __PLUGIN__
-
 #include <vlc_fourcc.h>
 
 #define TEST_FLAG_CONVERTER 0x01


=====================================
test/modules/stream_out/transcode_scenarios.c
=====================================
@@ -24,10 +24,6 @@
 # include "config.h"
 #endif
 
-#define MODULE_NAME test_transcode_mock
-#define MODULE_STRING "test_transcode_mock"
-#undef __PLUGIN__
-
 #include <vlc_common.h>
 #include <vlc_frame.h>
 


=====================================
test/src/input/decoder/input_decoder.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_input_decoder_mock
 #define MODULE_STRING "test_input_decoder_mock"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 
 const char vlc_module_name[] = MODULE_STRING;
 
@@ -324,10 +324,7 @@ vlc_module_begin()
 
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
-VLC_EXPORT vlc_plugin_cb vlc_static_modules[] = {
+VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL
 };


=====================================
test/src/input/decoder/input_decoder_scenarios.c
=====================================
@@ -24,9 +24,7 @@
 # include "config.h"
 #endif
 
-#define MODULE_NAME test_input_decoder_mock
 #define MODULE_STRING "test_input_decoder_mock"
-#undef __PLUGIN__
 
 #include <vlc_common.h>
 #include <vlc_messages.h>


=====================================
test/src/input/demux-run.c
=====================================
@@ -394,9 +394,6 @@ int vlc_demux_process_memory(const struct vlc_run_args *args,
 #ifdef HAVE_STATIC_MODULES
 # include <vlc_plugin.h>
 
-typedef int (*vlc_plugin_cb)(int (*)(void *, void *, int, ...), void *);
-extern vlc_plugin_cb vlc_static_modules[];
-
 #ifdef HAVE_DECODERS
 #define DECODER_PLUGINS(f) \
     f(codec_adpcm) \
@@ -481,13 +478,15 @@ extern vlc_plugin_cb vlc_static_modules[];
 #endif
 
 #define DECL_PLUGIN(p) \
-    int vlc_entry__##p(int (*)(void *, void *, int, ...), void *);
+    vlc_plugin_cb CONCATENATE(vlc_entry,p);
 
 #define FUNC_PLUGIN(p) \
-    vlc_entry__##p,
+    CONCATENATE(vlc_entry,p),
 
 PLUGINS(DECL_PLUGIN)
 
-__attribute__((visibility("default")))
-vlc_plugin_cb vlc_static_modules[] = { PLUGINS(FUNC_PLUGIN) NULL };
+VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
+    PLUGINS(FUNC_PLUGIN)
+    NULL
+};
 #endif /* HAVE_STATIC_MODULES */


=====================================
test/src/misc/image.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_misc_image
 #define MODULE_STRING "test_misc_image"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
@@ -140,9 +140,6 @@ vlc_module_begin()
 
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
 VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL


=====================================
test/src/misc/image_cvpx.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_misc_image_cvpx
 #define MODULE_STRING "test_misc_image_cvpx"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
@@ -96,9 +96,6 @@ vlc_module_begin()
     set_capability("interface", 0)
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
 VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL


=====================================
test/src/video_output/opengl.c
=====================================
@@ -25,7 +25,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_offscreen_mock
 #define MODULE_STRING "test_offscreen_mock"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 
 #include "../../libvlc/test.h"
 #include "../../../lib/libvlc_internal.h"
@@ -167,9 +167,6 @@ static int
 OpenOpenGLESOffscreen(vlc_gl_t *gl, unsigned width, unsigned height)
     { return OpenOpenGLCommon(gl, width, height, true, VLC_OPENGL_ES2); };
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
 /**
  * Inject the mocked modules as a static plugin:
  *  - decoder device for generating video context and testing release
@@ -201,8 +198,10 @@ vlc_module_begin()
         set_capability("opengl es2 offscreen", 1)
 vlc_module_end()
 
-VLC_EXPORT vlc_plugin_cb
-vlc_static_modules[] = { vlc_entry__test_offscreen_mock, NULL };
+VLC_EXPORT vlc_plugin_cb vlc_static_modules[] = {
+    VLC_SYMBOL(vlc_entry),
+    NULL
+};
 
 static void test_opengl_offscreen(vlc_object_t *root, enum vlc_gl_api_type api_type)
 {


=====================================
test/src/video_output/video_output.c
=====================================
@@ -27,7 +27,7 @@
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_vout_mock
 #define MODULE_STRING "test_vout_mock"
-#undef __PLUGIN__
+#undef VLC_DYNAMIC_PLUGIN
 
 static const char dec_dev_arg[] = "--dec-dev=" MODULE_STRING;
 
@@ -284,12 +284,7 @@ vlc_module_begin()
 
 vlc_module_end()
 
-/* Helper typedef for vlc_static_modules */
-typedef int (*vlc_plugin_cb)(vlc_set_cb, void*);
-
-
-VLC_EXPORT const vlc_plugin_cb vlc_static_modules[];
-const vlc_plugin_cb vlc_static_modules[] = {
+VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL
 };


=====================================
test/src/video_output/video_output.h
=====================================
@@ -20,10 +20,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#define MODULE_NAME test_vout_mock
-#define MODULE_STRING "test_vout_mock"
-#undef __PLUGIN__
-
 #include <vlc_fourcc.h>
 #include <vlc_vout_display.h>
 


=====================================
test/src/video_output/video_output_scenarios.c
=====================================
@@ -24,10 +24,6 @@
 # include "config.h"
 #endif
 
-#define MODULE_NAME test_vout_mock
-#define MODULE_STRING "test_vout_mock"
-#undef __PLUGIN__
-
 #include <vlc_common.h>
 #include "video_output.h"
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e09c4f9039ea2ebb53b07f1c11aa29e531bc2a56...63357faa16f84eecbdb4a3dcf0ef4a7557de5257

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e09c4f9039ea2ebb53b07f1c11aa29e531bc2a56...63357faa16f84eecbdb4a3dcf0ef4a7557de5257
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list