From 7d4fcdc5cf64affe0a2d9e5fa82fa0fb794401d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 11 Jul 2010 10:47:37 +0200 Subject: [PATCH] frei0r: Use correct order of directories to search for plugins And don't fail if a plugin was already registered. Frei0r allows plugins in directories with higher importance to override plugins from directories with lower importance. --- gst/frei0r/gstfrei0r.c | 28 +++++++++++++++++++++------- gst/frei0r/gstfrei0r.h | 6 ++++++ gst/frei0r/gstfrei0rfilter.c | 11 ++++++----- gst/frei0r/gstfrei0rfilter.h | 2 +- gst/frei0r/gstfrei0rmixer.c | 13 +++++++------ gst/frei0r/gstfrei0rmixer.h | 2 +- gst/frei0r/gstfrei0rsrc.c | 11 ++++++----- gst/frei0r/gstfrei0rsrc.h | 2 +- 8 files changed, 49 insertions(+), 26 deletions(-) diff --git a/gst/frei0r/gstfrei0r.c b/gst/frei0r/gstfrei0r.c index 82ff06f58c..baca1a81ab 100644 --- a/gst/frei0r/gstfrei0r.c +++ b/gst/frei0r/gstfrei0r.c @@ -460,7 +460,7 @@ static gboolean register_plugin (GstPlugin * plugin, const gchar * filename) { GModule *module; - gboolean ret = FALSE; + GstFrei0rPluginRegisterReturn ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED; GstFrei0rFuncTable ftable = { NULL, }; gint i; f0r_plugin_info_t info = { NULL, }; @@ -560,10 +560,24 @@ register_plugin (GstPlugin * plugin, const gchar * filename) break; } - if (!ret) - goto invalid_frei0r_plugin; + switch (ret) { + case GST_FREI0R_PLUGIN_REGISTER_RETURN_OK: + return TRUE; + case GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED: + GST_ERROR ("Failed to register frei0r plugin"); + ftable.deinit (); + g_module_close (module); + return FALSE; + case GST_FREI0R_PLUGIN_REGISTER_RETURN_ALREADY_REGISTERED: + GST_DEBUG ("frei0r plugin already registered"); + ftable.deinit (); + g_module_close (module); + return TRUE; + default: + g_return_val_if_reached (FALSE); + } - return ret; + g_return_val_if_reached (FALSE); invalid_frei0r_plugin: GST_ERROR ("Invalid frei0r plugin"); @@ -620,14 +634,14 @@ plugin_init (GstPlugin * plugin) "/usr/lib/frei0r-1:/usr/local/lib/frei0r-1", NULL, GST_PLUGIN_DEPENDENCY_FLAG_RECURSE); - register_plugins (plugin, "/usr/lib/frei0r-1"); - register_plugins (plugin, "/usr/local/lib/frei0r-1"); - homedir = g_get_home_dir (); path = g_build_filename (homedir, ".frei0r-1", NULL); register_plugins (plugin, path); g_free (path); + register_plugins (plugin, "/usr/local/lib/frei0r-1"); + register_plugins (plugin, "/usr/lib/frei0r-1"); + return TRUE; } diff --git a/gst/frei0r/gstfrei0r.h b/gst/frei0r/gstfrei0r.h index da24b43180..af2126542d 100644 --- a/gst/frei0r/gstfrei0r.h +++ b/gst/frei0r/gstfrei0r.h @@ -75,6 +75,12 @@ struct _GstFrei0rFuncTable { uint32_t* outframe); }; +typedef enum { + GST_FREI0R_PLUGIN_REGISTER_RETURN_OK, + GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED, + GST_FREI0R_PLUGIN_REGISTER_RETURN_ALREADY_REGISTERED +} GstFrei0rPluginRegisterReturn; + void gst_frei0r_klass_install_properties (GObjectClass *gobject_class, GstFrei0rFuncTable *ftable, GstFrei0rProperty *properties, gint n_properties); f0r_instance_t * gst_frei0r_instance_construct (GstFrei0rFuncTable *ftable, GstFrei0rProperty *properties, gint n_properties, GstFrei0rPropertyValue *property_cache, gint width, gint height); diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c index cc0c3d2774..cca29fccd4 100644 --- a/gst/frei0r/gstfrei0rfilter.c +++ b/gst/frei0r/gstfrei0rfilter.c @@ -226,7 +226,7 @@ gst_frei0r_filter_init (GstFrei0rFilter * self, GstFrei0rFilterClass * klass) gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SRC_PAD (self)); } -gboolean +GstFrei0rPluginRegisterReturn gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, const GstFrei0rFuncTable * ftable) { @@ -244,7 +244,7 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, GType type; gchar *type_name, *tmp; GstFrei0rFilterClassData *class_data; - gboolean ret = FALSE; + GstFrei0rPluginRegisterReturn ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED; tmp = g_strdup_printf ("frei0r-filter-%s", info->name); type_name = g_ascii_strdown (tmp, -1); @@ -252,8 +252,8 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-'); if (g_type_from_name (type_name)) { - GST_WARNING ("Type '%s' already exists", type_name); - return FALSE; + GST_DEBUG ("Type '%s' already exists", type_name); + return GST_FREI0R_PLUGIN_REGISTER_RETURN_ALREADY_REGISTERED; } class_data = g_new0 (GstFrei0rFilterClassData, 1); @@ -263,7 +263,8 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info, type = g_type_register_static (GST_TYPE_VIDEO_FILTER, type_name, &typeinfo, 0); - ret = gst_element_register (plugin, type_name, GST_RANK_NONE, type); + if (gst_element_register (plugin, type_name, GST_RANK_NONE, type)) + ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_OK; g_free (type_name); return ret; diff --git a/gst/frei0r/gstfrei0rfilter.h b/gst/frei0r/gstfrei0rfilter.h index b85c3f6e46..1b1914a94e 100644 --- a/gst/frei0r/gstfrei0rfilter.h +++ b/gst/frei0r/gstfrei0rfilter.h @@ -58,7 +58,7 @@ struct _GstFrei0rFilterClass { gint n_properties; }; -gboolean gst_frei0r_filter_register (GstPlugin *plugin, const f0r_plugin_info_t *info, const GstFrei0rFuncTable *ftable); +GstFrei0rPluginRegisterReturn gst_frei0r_filter_register (GstPlugin *plugin, const f0r_plugin_info_t *info, const GstFrei0rFuncTable *ftable); G_END_DECLS diff --git a/gst/frei0r/gstfrei0rmixer.c b/gst/frei0r/gstfrei0rmixer.c index 5172e28c16..f61a573411 100644 --- a/gst/frei0r/gstfrei0rmixer.c +++ b/gst/frei0r/gstfrei0rmixer.c @@ -767,7 +767,7 @@ gst_frei0r_mixer_init (GstFrei0rMixer * self, GstFrei0rMixerClass * klass) } -gboolean +GstFrei0rPluginRegisterReturn gst_frei0r_mixer_register (GstPlugin * plugin, const f0r_plugin_info_t * info, const GstFrei0rFuncTable * ftable) { @@ -785,10 +785,10 @@ gst_frei0r_mixer_register (GstPlugin * plugin, const f0r_plugin_info_t * info, GType type; gchar *type_name, *tmp; GstFrei0rMixerClassData *class_data; - gboolean ret = FALSE; + GstFrei0rPluginRegisterReturn ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED; if (ftable->update2 == NULL) - return FALSE; + return GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED; tmp = g_strdup_printf ("frei0r-mixer-%s", info->name); type_name = g_ascii_strdown (tmp, -1); @@ -796,8 +796,8 @@ gst_frei0r_mixer_register (GstPlugin * plugin, const f0r_plugin_info_t * info, g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-'); if (g_type_from_name (type_name)) { - GST_WARNING ("Type '%s' already exists", type_name); - return FALSE; + GST_DEBUG ("Type '%s' already exists", type_name); + return GST_FREI0R_PLUGIN_REGISTER_RETURN_ALREADY_REGISTERED; } class_data = g_new0 (GstFrei0rMixerClassData, 1); @@ -806,7 +806,8 @@ gst_frei0r_mixer_register (GstPlugin * plugin, const f0r_plugin_info_t * info, typeinfo.class_data = class_data; type = g_type_register_static (GST_TYPE_ELEMENT, type_name, &typeinfo, 0); - ret = gst_element_register (plugin, type_name, GST_RANK_NONE, type); + if (gst_element_register (plugin, type_name, GST_RANK_NONE, type)) + ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_OK; g_free (type_name); return ret; diff --git a/gst/frei0r/gstfrei0rmixer.h b/gst/frei0r/gstfrei0rmixer.h index 548b70ec76..f077d341a4 100644 --- a/gst/frei0r/gstfrei0rmixer.h +++ b/gst/frei0r/gstfrei0rmixer.h @@ -68,7 +68,7 @@ struct _GstFrei0rMixerClass { gint n_properties; }; -gboolean gst_frei0r_mixer_register (GstPlugin *plugin, const f0r_plugin_info_t *info, const GstFrei0rFuncTable *ftable); +GstFrei0rPluginRegisterReturn gst_frei0r_mixer_register (GstPlugin *plugin, const f0r_plugin_info_t *info, const GstFrei0rFuncTable *ftable); G_END_DECLS diff --git a/gst/frei0r/gstfrei0rsrc.c b/gst/frei0r/gstfrei0rsrc.c index e811b46d75..1e6beeefac 100644 --- a/gst/frei0r/gstfrei0rsrc.c +++ b/gst/frei0r/gstfrei0rsrc.c @@ -391,7 +391,7 @@ gst_frei0r_src_init (GstFrei0rSrc * self, GstFrei0rSrcClass * klass) gst_base_src_set_format (GST_BASE_SRC_CAST (self), GST_FORMAT_TIME); } -gboolean +GstFrei0rPluginRegisterReturn gst_frei0r_src_register (GstPlugin * plugin, const f0r_plugin_info_t * info, const GstFrei0rFuncTable * ftable) { @@ -409,7 +409,7 @@ gst_frei0r_src_register (GstPlugin * plugin, const f0r_plugin_info_t * info, GType type; gchar *type_name, *tmp; GstFrei0rSrcClassData *class_data; - gboolean ret = FALSE; + GstFrei0rPluginRegisterReturn ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED; tmp = g_strdup_printf ("frei0r-src-%s", info->name); type_name = g_ascii_strdown (tmp, -1); @@ -417,8 +417,8 @@ gst_frei0r_src_register (GstPlugin * plugin, const f0r_plugin_info_t * info, g_strcanon (type_name, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-+", '-'); if (g_type_from_name (type_name)) { - GST_WARNING ("Type '%s' already exists", type_name); - return FALSE; + GST_DEBUG ("Type '%s' already exists", type_name); + return GST_FREI0R_PLUGIN_REGISTER_RETURN_ALREADY_REGISTERED; } class_data = g_new0 (GstFrei0rSrcClassData, 1); @@ -427,7 +427,8 @@ gst_frei0r_src_register (GstPlugin * plugin, const f0r_plugin_info_t * info, typeinfo.class_data = class_data; type = g_type_register_static (GST_TYPE_PUSH_SRC, type_name, &typeinfo, 0); - ret = gst_element_register (plugin, type_name, GST_RANK_NONE, type); + if (gst_element_register (plugin, type_name, GST_RANK_NONE, type)) + ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_OK; g_free (type_name); return ret; diff --git a/gst/frei0r/gstfrei0rsrc.h b/gst/frei0r/gstfrei0rsrc.h index 291a644b9a..e5a71b738c 100644 --- a/gst/frei0r/gstfrei0rsrc.h +++ b/gst/frei0r/gstfrei0rsrc.h @@ -62,7 +62,7 @@ struct _GstFrei0rSrcClass { gint n_properties; }; -gboolean gst_frei0r_src_register (GstPlugin *plugin, const f0r_plugin_info_t *info, const GstFrei0rFuncTable *ftable); +GstFrei0rPluginRegisterReturn gst_frei0r_src_register (GstPlugin *plugin, const f0r_plugin_info_t *info, const GstFrei0rFuncTable *ftable); G_END_DECLS