gst/gstplugin.c: apply patch from #172526 to make register work on MacOSX

Original commit message from CVS:

* gst/gstplugin.c: (gst_plugin_check_module),
(gst_plugin_check_file), (gst_plugin_load_file):
apply patch from #172526 to make register work on MacOSX
This commit is contained in:
Thomas Vander Stichele 2005-05-03 12:46:47 +00:00
parent f1d70972b0
commit 5aed75335c
2 changed files with 56 additions and 40 deletions

View file

@ -1,9 +1,8 @@
2005-05-02 Thomas Vander Stichele <thomas at apestaart dot org> 2005-05-03 Thomas Vander Stichele <thomas at apestaart dot org>
reviewed by: <delete if not using a buddy> * gst/gstplugin.c: (gst_plugin_check_module),
(gst_plugin_check_file), (gst_plugin_load_file):
* testsuite/indexers/cache1.c: (lookup): apply patch from #172526 to make register work on MacOSX
* testsuite/indexers/indexdump.c: (main):
2005-05-02 Thomas Vander Stichele <thomas at apestaart dot org> 2005-05-02 Thomas Vander Stichele <thomas at apestaart dot org>

View file

@ -300,6 +300,46 @@ _gst_plugin_fault_handler_setup (void)
static void _gst_plugin_fault_handler_setup (); static void _gst_plugin_fault_handler_setup ();
/**
* gst_plugin_check_module:
* @module: GModule handle to check for pluginness
* @error: pointer to a NULL-valued GError
* @pptr: pointer to a gpointer used to return the gst_plugin_desc symbol
* (can be NULL)
*
* Checks if the given module is a GStreamer plugin
*
* Returns: TRUE if the given module is a GStreamer plugin
*/
static gboolean
gst_plugin_check_module (GModule * module, const char *filename,
GError ** error, gpointer * pptr)
{
gpointer ptr;
if (pptr == NULL)
pptr = &ptr;
if (module == NULL) {
GST_DEBUG ("Error loading plugin %s, reason: %s", filename,
g_module_error ());
g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE,
"Error loading plugin %s, reason: %s", filename, g_module_error ());
return FALSE;
}
if (!g_module_symbol (module, "gst_plugin_desc", pptr)) {
GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename);
g_set_error (error,
GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE,
"Could not find plugin entry point in \"%s\"", filename);
return FALSE;
}
return TRUE;
}
/** /**
* gst_plugin_check_file: * gst_plugin_check_file:
* @filename: the plugin filename to check for pluginness * @filename: the plugin filename to check for pluginness
@ -314,7 +354,7 @@ gst_plugin_check_file (const gchar * filename, GError ** error)
{ {
GModule *module; GModule *module;
struct stat file_status; struct stat file_status;
gpointer ptr; gboolean check;
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
@ -334,28 +374,13 @@ gst_plugin_check_file (const gchar * filename, GError ** error)
} }
module = g_module_open (filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); module = g_module_open (filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
check = gst_plugin_check_module (module, filename, error, NULL);
if (module == NULL) {
GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename,
g_module_error ());
g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE,
"Error loading plugin %s, reason: %s\n", filename, g_module_error ());
return FALSE;
}
if (!g_module_symbol (module, "gst_plugin_desc", &ptr)) {
GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename);
g_set_error (error,
GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE,
"Could not find plugin entry point in \"%s\"", filename);
g_module_close (module);
return FALSE;
}
/* it's a plugin */
GST_INFO ("looks like a gst plugin \"%s\"", filename);
g_module_close (module); g_module_close (module);
return TRUE;
GST_INFO ("file \"%s\" %s look like a gst plugin", filename,
check ? "does" : "doesn't");
return check;
} }
/** /**
@ -381,16 +406,11 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"", GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"",
filename); filename);
if (!gst_plugin_check_file (filename, error))
return NULL;
module = g_module_open (filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); module = g_module_open (filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
if (module == NULL) /* handle module == NULL case */
goto load_error; if (!gst_plugin_check_module (module, filename, error, &ptr))
return NULL;
if (!g_module_symbol (module, "gst_plugin_desc", &ptr))
goto load_error;
desc = (GstPluginDesc *) ptr; desc = (GstPluginDesc *) ptr;
@ -403,6 +423,7 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
} else { } else {
free_plugin = FALSE; free_plugin = FALSE;
if (gst_plugin_is_loaded (plugin)) { if (gst_plugin_is_loaded (plugin)) {
g_module_close (module);
if (plugin->filename && strcmp (plugin->filename, filename) != 0) { if (plugin->filename && strcmp (plugin->filename, filename) != 0) {
GST_WARNING GST_WARNING
("plugin %p from file \"%s\" with same name %s is already " ("plugin %p from file \"%s\" with same name %s is already "
@ -455,15 +476,11 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
GST_PLUGIN_ERROR, GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE, GST_PLUGIN_ERROR_MODULE,
"gst_plugin_register_func failed for plugin \"%s\"", filename); "gst_plugin_register_func failed for plugin \"%s\"", filename);
g_module_close (module);
if (free_plugin) if (free_plugin)
g_free (plugin); g_free (plugin);
return NULL; return NULL;
} }
load_error:
g_set_error (error,
GST_PLUGIN_ERROR,
GST_PLUGIN_ERROR_MODULE, "generic load error for \"%s\"", filename);
return NULL;
} }
static void static void