2008-01-09 Tim-Philipp Müller <tim at centricular dot net>
+ * docs/gst/gstreamer-sections.txt:
+ * gst/gst.c: (init_post):
+ * gst/gstplugin.c: (_gst_plugin_register_static),
+ (gst_plugin_register_static), (_gst_plugin_initialize),
+ (gst_plugin_register_func):
+ * gst/gstplugin.h: (GST_PLUGIN_DEFINE_STATIC):
+ API: add gst_plugin_register_static() and deprecate
+ GST_PLUGIN_DEFINE_STATIC, since it's not portable
+ (#498924).
+ Also, in _gst_plugin_register_static(), make sure to call
+ g_thread_init() before calling GLib functions such as
+ g_list_append() if we're not initialised yet, since that
+ may lead to random crashes with older GSlice/GLib versions.
+
+ * tests/check/gst/gstplugin.c:
+ Adapt unit test to above changes.
+
+2008-01-09 Tim-Philipp Müller <tim at centricular dot net>
+
* gst/gst_private.h: (STRUCTURE_ESTIMATED_STRING_LEN):
* gst/gstcaps.c: (gst_caps_to_string):
* gst/gststructure.c: (GST_ASCII_IS_STRING),
gst_plugin_load
gst_plugin_load_by_name
gst_plugin_list_free
+gst_plugin_register_static
<SUBSECTION Standard>
GstPluginClass
GST_PLUGIN
_gst_message_initialize ();
_gst_tag_initialize ();
- /* register core plugins */
- _gst_plugin_register_static (&plugin_desc);
-
_gst_plugin_initialize ();
+ /* register core plugins */
+ gst_plugin_register_static (&plugin_desc);
+
/*
* Any errors happening below this point are non-fatal, we therefore mark
* gstreamer as being initialized, since it is the case from a plugin point of
};
static GstPlugin *gst_plugin_register_func (GstPlugin * plugin,
- GstPluginDesc * desc);
+ const GstPluginDesc * desc);
static void gst_plugin_desc_copy (GstPluginDesc * dest,
const GstPluginDesc * src);
static void gst_plugin_desc_free (GstPluginDesc * desc);
return quark;
}
+#ifndef GST_REMOVE_DEPRECATED
/* this function can be called in the GCC constructor extension, before
* the _gst_plugin_initialize() was called. In that case, we store the
* plugin description in a list to initialize it when we open the main
void
_gst_plugin_register_static (GstPluginDesc * desc)
{
+ g_return_if_fail (desc != NULL);
+
if (!_gst_plugin_inited) {
+ /* Must call g_thread_init() before calling GLib functions such as
+ * g_list_prepend() ... */
+ if (!g_thread_supported ())
+ g_thread_init (NULL);
+
if (GST_CAT_DEFAULT)
GST_LOG ("queueing static plugin \"%s\" for loading later on",
desc->name);
_gst_plugin_static = g_list_prepend (_gst_plugin_static, desc);
} else {
- GstPlugin *plugin;
+ gst_plugin_register_static (desc);
+ }
+}
+#endif
- if (GST_CAT_DEFAULT)
- GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name);
- plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
- if (gst_plugin_register_func (plugin, desc)) {
- if (GST_CAT_DEFAULT)
- GST_INFO ("loaded static plugin \"%s\"", desc->name);
- gst_default_registry_add_plugin (plugin);
- }
+/**
+ * gst_plugin_register_static:
+ * @desc: a #GstPluginDesc describing the plugin.
+ *
+ * Registers a static plugin, ie. a plugin which is private to an application
+ * or library and contained within the application or library (as opposed to
+ * being shipped as a separate module file).
+ *
+ * You must make sure that GStreamer has been initialised (with gst_init() or
+ * via gst_init_get_option_group()) before calling this function.
+ *
+ * Returns: TRUE if the plugin was registered correctly, otherwise FALSE.
+ *
+ * Since: 0.10.16
+ */
+gboolean
+gst_plugin_register_static (const GstPluginDesc * desc)
+{
+ GstPlugin *plugin;
+ gboolean res = FALSE;
+
+ g_return_val_if_fail (desc != NULL, FALSE);
+
+ /* make sure gst_init() has been called */
+ g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
+
+ GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name);
+ plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
+ if (gst_plugin_register_func (plugin, desc) != NULL) {
+ GST_INFO ("loaded static plugin \"%s\"", desc->name);
+ res = gst_default_registry_add_plugin (plugin);
}
+ return res;
}
void
_gst_plugin_inited = TRUE;
/* now register all static plugins */
- g_list_foreach (_gst_plugin_static, (GFunc) _gst_plugin_register_static,
- NULL);
+ g_list_foreach (_gst_plugin_static, (GFunc) gst_plugin_register_static, NULL);
}
/* this function could be extended to check if the plugin license matches the
}
static GstPlugin *
-gst_plugin_register_func (GstPlugin * plugin, GstPluginDesc * desc)
+gst_plugin_register_func (GstPlugin * plugin, const GstPluginDesc * desc)
{
if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) {
if (GST_CAT_DEFAULT)
GST_PADDING_INIT \
};
+#ifndef GST_DISABLE_DEPRECATED
/**
* GST_PLUGIN_DEFINE_STATIC:
* @major: major version number of the gstreamer-core that plugin was compiled for
* This macro needs to be used to define the entry point and meta data of a
* local plugin. One would use this macro to define a local plugin that can only
* be used by the own application.
+ *
+ * Deprecated: Use gst_plugin_register_static() instead. This macro was
+ * deprecated because it uses constructors, which is a compiler feature not
+ * available on all compilers.
*/
#define GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin) \
static void GST_GNUC_CONSTRUCTOR \
}; \
_gst_plugin_register_static (&plugin_desc_); \
}
+#endif
/**
* GST_LICENSE_UNKNOWN:
GType gst_plugin_get_type (void);
+#ifndef GST_DISABLE_DEPRECATED
void _gst_plugin_register_static (GstPluginDesc *desc);
+#endif
+
+gboolean gst_plugin_register_static (const GstPluginDesc *desc);
G_CONST_RETURN gchar* gst_plugin_get_name (GstPlugin *plugin);
G_CONST_RETURN gchar* gst_plugin_get_description (GstPlugin *plugin);
#include <gst/check/gstcheck.h>
+#ifdef GST_DISABLE_DEPRECATED
+void _gst_plugin_register_static (GstPluginDesc * desc);
+#endif
+
static gboolean
register_check_elements (GstPlugin * plugin)
{
GST_PADDING_INIT
};
+static GstPluginDesc plugin_desc2 = {
+ GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "more-elements",
+ "more-elements",
+ register_check_elements,
+ VERSION,
+ GST_LICENSE,
+ PACKAGE,
+ GST_PACKAGE_NAME,
+ GST_PACKAGE_ORIGIN,
+
+ GST_PADDING_INIT
+};
+
GST_START_TEST (test_register_static)
{
GstPlugin *plugin;
_gst_plugin_register_static (&plugin_desc);
+ gst_plugin_register_static (&plugin_desc2);
plugin = g_object_new (GST_TYPE_PLUGIN, NULL);