diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2014-10-30 19:36:25 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2015-02-25 16:43:45 -0500 |
commit | 45861c192761b7059a6ffd4b6daea2ebcdd82642 (patch) | |
tree | 1cd12d6486d920a24b7fa668cc95e08abcfe6605 /farstream | |
parent | adb4765979f627dfce44590b243cd74af086da9a (diff) | |
download | farstream-45861c192761b7059a6ffd4b6daea2ebcdd82642.tar.gz |
Enable building static FsPlugins
This required change FS_INIT_PLUGIN() macro. It's now taking name and
type argumenet. This is a slight API break, but there never existed any
external plugins. Also, already built plugins should not be affected since
the symbol remains the same.
Note also that plugin are no longer unloadable, it was already not well
supported. Instead of adding loads of if, we simply register the module
types as static (just like GStreamer does).
To register static plugin, you can declare it's registration function
using FS_PLUGIN_STATIC_DECLARE(name), and then in your code call the
function using FS_PLUGIN_STATIC_REGISTER(name).
https://bugs.freedesktop.org/show_bug.cgi?id=89287
Diffstat (limited to 'farstream')
-rw-r--r-- | farstream/fs-plugin.c | 23 | ||||
-rw-r--r-- | farstream/fs-plugin.h | 50 |
2 files changed, 70 insertions, 3 deletions
diff --git a/farstream/fs-plugin.c b/farstream/fs-plugin.c index 05a3bd4c..656d9d78 100644 --- a/farstream/fs-plugin.c +++ b/farstream/fs-plugin.c @@ -390,3 +390,26 @@ fs_plugin_list_available (const gchar *type_suffix) return retval; } + +/** + * fs_plugin_register_static: + * @name: The name of the plugin to register + * @type_suffix: The type of plugin to register (normally "transmitter") + * + * Register a staticly linked transmitter. This function should strictly be + * used by plugins own register function. To register a static plugin: + * extern fs_plugin_<name>_<type>_register_pluing (void); + * fs_plugin_<name>_<type>_register_pluing (); + **/ + +void +fs_plugin_register_static (const gchar *name, const gchar *type_suffix, GType type) +{ + FsPlugin *plugin; + + plugin = g_object_new (FS_TYPE_PLUGIN, NULL); + plugin->name = g_strdup_printf ("%s-%s", name, type_suffix); + g_type_module_set_name (G_TYPE_MODULE (plugin), plugin->name); + plugin->type = type; + plugins = g_list_append (plugins, plugin); +} diff --git a/farstream/fs-plugin.h b/farstream/fs-plugin.h index c6d0a216..abcbe453 100644 --- a/farstream/fs-plugin.h +++ b/farstream/fs-plugin.h @@ -104,6 +104,9 @@ GObject *fs_plugin_create (const gchar *name, gchar **fs_plugin_list_available (const gchar *type_suffix); +void fs_plugin_register_static (const gchar *name, const gchar *type_suffix, + GType type); + /** * FS_INIT_PLUGIN: * @type_register_func: A function that register a #GType and returns it @@ -112,11 +115,52 @@ gchar **fs_plugin_list_available (const gchar *type_suffix); * in any farstream plugin. */ -#define FS_INIT_PLUGIN(type_register_func) \ - G_MODULE_EXPORT void fs_init_plugin (FsPlugin *plugin) { \ - plugin->type = (type_register_func (plugin)); \ +#define _FS_REGISTER_TYPE(plugin,name,type) \ + fs_ ## name ## _ ## type ## _register_type (plugin) + +#ifdef GST_PLUGIN_BUILD_STATIC + +#define FS_INIT_PLUGIN(name,type) \ + G_MODULE_EXPORT void \ + fs_plugin_ ## name ## _ ## type ## _register (void) \ + { \ + fs_plugin_register_static (#name, #type, \ + _FS_REGISTER_TYPE (NULL, name, type)); \ } +#else /* !GST_PLUGIN_BUILD_STATIC */ + +#define FS_INIT_PLUGIN(name,_type) \ + G_MODULE_EXPORT void \ + fs_init_plugin (FsPlugin *plugin) \ + { \ + plugin->type = _FS_REGISTER_TYPE (plugin, name, _type); \ + } + +#endif /* GST_PLUGIN_BUILD_STATIC */ + +/** + * FS_PLUGIN_STATIC_DECLARE: + * @name: unique name of the plugin + * + * This macro can be used to initialize statically linked plugins. It is + * necessary to call this macro before the plugin can be used. It has to be + * used in combination with FS_PLUGIN_STATIC_REGISTER and must be placed + * outside any block to declare the plugin initialization function. + */ +#define FS_PLUGIN_STATIC_DECLARE(name) \ + extern void fs_plugin_ ## name ## _register(void); + +/** + * FS_PLUGIN_STATIC_REGISTER: + * @name: unique name of the plugin + * + * This macro can be used to initialize statically linked plugins. It is + * necessary to call this macro before the plugin can be used. It has to + * be used in combination with FS_PLUGIN_STATIC_DECLARE and calls the plugin + * initialization function. + */ +#define FS_PLUGIN_STATIC_REGISTER(name) fs_plugin_ ## name ## _register () G_END_DECLS #endif |