Commit 70be8d8d authored by Wim Taymans's avatar Wim Taymans

improve type registration

parent cdde34f0
......@@ -667,6 +667,8 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
_priv_gst_quarks_initialize ();
_gst_format_initialize ();
_gst_query_initialize ();
_gst_caps_initialize ();
g_type_class_ref (gst_object_get_type ());
g_type_class_ref (gst_pad_get_type ());
g_type_class_ref (gst_element_factory_get_type ());
......@@ -751,7 +753,6 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
gst_structure_get_type ();
_gst_value_initialize ();
g_type_class_ref (gst_param_spec_fraction_get_type ());
gst_caps_get_type ();
_gst_event_initialize ();
_gst_buffer_initialize ();
_gst_buffer_list_initialize ();
......
......@@ -98,6 +98,7 @@ void _priv_gst_quarks_initialize (void);
* we want enterprise edition packagers dancing on our heads) */
void _gst_buffer_initialize (void);
void _gst_buffer_list_initialize (void);
void _gst_caps_initialize (void);
void _gst_event_initialize (void);
void _gst_format_initialize (void);
void _gst_message_initialize (void);
......
......@@ -128,16 +128,7 @@
#include "gstminiobject.h"
#include "gstversion.h"
static GType _gst_buffer_type = 0;
GType
gst_buffer_get_type (void)
{
if (G_UNLIKELY (_gst_buffer_type == 0)) {
_gst_buffer_type = gst_mini_object_register ("GstBuffer");
}
return _gst_buffer_type;
}
GType _gst_buffer_type = 0;
/* buffer alignment in bytes
* an alignment of 8 would be the same as malloc() guarantees
......@@ -167,15 +158,14 @@ aligned_malloc (gpointer * memptr, guint size)
void
_gst_buffer_initialize (void)
{
/* the GstMiniObject types need to be class_ref'd once before it can be
* done from multiple threads;
* see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
gst_buffer_get_type ();
if (G_LIKELY (_gst_buffer_type == 0)) {
_gst_buffer_type = gst_mini_object_register ("GstBuffer");
#ifdef HAVE_GETPAGESIZE
#ifdef BUFFER_ALIGNMENT_PAGESIZE
_gst_buffer_data_alignment = getpagesize ();
_gst_buffer_data_alignment = getpagesize ();
#endif
#endif
}
}
/**
......@@ -337,7 +327,6 @@ gst_buffer_new (void)
* gst_buffer_try_new_and_alloc() if you want to handle this case
* gracefully or have gotten the size to allocate from an untrusted
* source such as a media stream.
*
*
* Note that when @size == 0, the buffer data pointer will be NULL.
*
......
......@@ -32,6 +32,8 @@ G_BEGIN_DECLS
typedef struct _GstBuffer GstBuffer;
extern GType _gst_buffer_type;
/**
* GST_BUFFER_TRACE_NAME:
*
......@@ -39,7 +41,7 @@ typedef struct _GstBuffer GstBuffer;
*/
#define GST_BUFFER_TRACE_NAME "GstBuffer"
#define GST_TYPE_BUFFER (gst_buffer_get_type())
#define GST_TYPE_BUFFER (_gst_buffer_type)
#define GST_IS_BUFFER(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_BUFFER))
#define GST_BUFFER_CAST(obj) ((GstBuffer *)(obj))
#define GST_BUFFER(obj) (GST_BUFFER_CAST(obj))
......@@ -287,8 +289,6 @@ struct _GstBuffer {
gpointer _gst_reserved[GST_PADDING];
};
GType gst_buffer_get_type (void);
/* allocation */
GstBuffer * gst_buffer_new (void);
GstBuffer * gst_buffer_new_and_alloc (guint size);
......
......@@ -159,14 +159,14 @@ struct _GstBufferListIterator
GList *last_returned;
};
static GType _gst_buffer_list_type = 0;
GType _gst_buffer_list_type = 0;
void
_gst_buffer_list_initialize (void)
{
GType type = gst_buffer_list_get_type ();
_gst_buffer_list_type = type;
if (G_LIKELY (_gst_buffer_list_type == 0)) {
_gst_buffer_list_type = gst_mini_object_register ("GstBufferList");
}
}
static GstBufferList *
......@@ -401,15 +401,6 @@ gst_buffer_list_get (GstBufferList * list, guint group, guint idx)
return NULL;
}
GType
gst_buffer_list_get_type (void)
{
if (G_UNLIKELY (_gst_buffer_list_type == 0)) {
_gst_buffer_list_type = gst_mini_object_register ("GstBufferList");
}
return _gst_buffer_list_type;
}
/**
* gst_buffer_list_iterate:
* @list: a #GstBufferList
......
......@@ -27,7 +27,9 @@
G_BEGIN_DECLS
#define GST_TYPE_BUFFER_LIST (gst_buffer_list_get_type ())
extern GType _gst_buffer_list_type;
#define GST_TYPE_BUFFER_LIST (_gst_buffer_list_type)
#define GST_IS_BUFFER_LIST(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_BUFFER_LIST))
#define GST_BUFFER_LIST_CAST(obj) ((GstBufferList *)obj)
#define GST_BUFFER_LIST(obj) (GST_BUFFER_LIST_CAST(obj))
......@@ -104,8 +106,6 @@ typedef GstBufferListItem (*GstBufferListFunc) (GstBuffer **buffer, guint grou
gpointer user_data);
GType gst_buffer_list_get_type (void);
/* allocation */
GstBufferList *gst_buffer_list_new (void);
......
......@@ -122,19 +122,17 @@ static void gst_caps_transform_to_string (const GValue * src_value,
static gboolean gst_caps_from_string_inplace (GstCaps * caps,
const gchar * string);
static GType _gst_caps_type = 0;
GType _gst_caps_type = 0;
GType
gst_caps_get_type (void)
void
_gst_caps_initialize (void)
{
if (G_UNLIKELY (_gst_caps_type == 0)) {
if (G_LIKELY (_gst_caps_type == 0)) {
_gst_caps_type = gst_mini_object_register ("GstCaps");
g_value_register_transform_func (_gst_caps_type,
G_TYPE_STRING, gst_caps_transform_to_string);
}
return _gst_caps_type;
}
static GstCaps *
......
......@@ -27,7 +27,9 @@
G_BEGIN_DECLS
#define GST_TYPE_CAPS (gst_caps_get_type())
extern GType _gst_caps_type;
#define GST_TYPE_CAPS (_gst_caps_type)
#define GST_CAPS(object) ((GstCaps*)object)
#define GST_IS_CAPS(object) (GST_IS_MINI_OBJECT_TYPE(object, GST_TYPE_CAPS))
......@@ -254,7 +256,6 @@ struct _GstStaticCaps {
gpointer _gst_reserved[GST_PADDING];
};
GType gst_caps_get_type (void);
GstCaps * gst_caps_new_empty (void);
GstCaps * gst_caps_new_any (void);
GstCaps * gst_caps_new_simple (const char *media_type,
......
......@@ -216,7 +216,7 @@ gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
g_object_class_install_property (gobject_class, PROP_CAPS,
g_param_spec_boxed ("caps", _("caps"),
_("detected capabilities in stream"), gst_caps_get_type (),
_("detected capabilities in stream"), GST_TYPE_CAPS,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MINIMUM,
g_param_spec_uint ("minimum", _("minimum"),
......@@ -230,7 +230,7 @@ gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_FORCE_CAPS,
g_param_spec_boxed ("force-caps", _("force caps"),
_("force caps without doing a typefind"), gst_caps_get_type (),
_("force caps without doing a typefind"), GST_TYPE_CAPS,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstTypeFindElement::have-type:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment