frei0r: Make plugin scanning more robust

This commit is contained in:
Sebastian Dröge 2009-06-16 21:34:56 +02:00
parent b30ebf0108
commit 29aa30d9a0
4 changed files with 20 additions and 15 deletions

View file

@ -426,6 +426,7 @@ register_plugin (GstPlugin * plugin, const gchar * filename)
GstFrei0rFuncTable ftable = { NULL, };
gint i;
f0r_plugin_info_t info = { NULL, };
f0r_instance_t *instance = NULL;
GST_DEBUG ("Registering plugin '%s'", filename);
@ -460,6 +461,12 @@ register_plugin (GstPlugin * plugin, const gchar * filename)
g_module_symbol (module, "f0r_update", (gpointer *) & ftable.update);
g_module_symbol (module, "f0r_update2", (gpointer *) & ftable.update2);
if (!ftable.init ()) {
GST_WARNING ("Failed to initialize plugin");
g_module_close (module);
return FALSE;
}
if (!ftable.update && !ftable.update2)
goto invalid_frei0r_plugin;
@ -467,12 +474,14 @@ register_plugin (GstPlugin * plugin, const gchar * filename)
if (info.frei0r_version > 1) {
GST_WARNING ("Unsupported frei0r version %d", info.frei0r_version);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
if (info.color_model > F0R_COLOR_MODEL_PACKED32) {
GST_WARNING ("Unsupported color model %d", info.color_model);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
@ -483,11 +492,21 @@ register_plugin (GstPlugin * plugin, const gchar * filename)
ftable.get_param_info (&pinfo, i);
if (pinfo.type > F0R_PARAM_STRING) {
GST_WARNING ("Unsupported parameter type %d", pinfo.type);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
}
instance = ftable.construct (640, 480);
if (!instance) {
GST_WARNING ("Failed to instanciate plugin '%s'", info.name);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
ftable.destruct (instance);
switch (info.plugin_type) {
case F0R_PLUGIN_TYPE_FILTER:
ret = gst_frei0r_filter_register (plugin, &info, &ftable);
@ -510,6 +529,7 @@ register_plugin (GstPlugin * plugin, const gchar * filename)
invalid_frei0r_plugin:
GST_ERROR ("Invalid frei0r plugin");
ftable.deinit ();
g_module_close (module);
return FALSE;

View file

@ -227,11 +227,6 @@ gst_frei0r_filter_register (GstPlugin * plugin, const f0r_plugin_info_t * info,
return FALSE;
}
if (!ftable->init ()) {
GST_ERROR ("Initializing plugin failed");
return FALSE;
}
class_data = g_new0 (GstFrei0rFilterClassData, 1);
memcpy (&class_data->info, info, sizeof (f0r_plugin_info_t));
memcpy (&class_data->ftable, ftable, sizeof (GstFrei0rFuncTable));

View file

@ -769,11 +769,6 @@ gst_frei0r_mixer_register (GstPlugin * plugin, const f0r_plugin_info_t * info,
return FALSE;
}
if (!ftable->init ()) {
GST_ERROR ("Initializing plugin failed");
return FALSE;
}
class_data = g_new0 (GstFrei0rMixerClassData, 1);
memcpy (&class_data->info, info, sizeof (f0r_plugin_info_t));
memcpy (&class_data->ftable, ftable, sizeof (GstFrei0rFuncTable));

View file

@ -398,11 +398,6 @@ gst_frei0r_src_register (GstPlugin * plugin, const f0r_plugin_info_t * info,
return FALSE;
}
if (!ftable->init ()) {
GST_ERROR ("Initializing plugin failed");
return FALSE;
}
class_data = g_new0 (GstFrei0rSrcClassData, 1);
memcpy (&class_data->info, info, sizeof (f0r_plugin_info_t));
memcpy (&class_data->ftable, ftable, sizeof (GstFrei0rFuncTable));