gst: Use G_DEFINE_TYPE and friends or at least g_once_init_* in the _get_type() functions

This commit is contained in:
Sebastian Dröge 2009-04-04 10:20:36 +02:00
parent 42febffe0d
commit e7ccf786c3
22 changed files with 200 additions and 612 deletions

View file

@ -274,60 +274,35 @@ enum
/* FILL ME */
};
static void gst_bin_base_init (gpointer g_class);
static void gst_bin_class_init (GstBinClass * klass);
static void gst_bin_init (GstBin * bin);
static void gst_bin_child_proxy_init (gpointer g_iface, gpointer iface_data);
static GstElementClass *parent_class = NULL;
static guint gst_bin_signals[LAST_SIGNAL] = { 0 };
GType
gst_bin_get_type (void)
{
static GType gst_bin_type = 0;
const gchar *compat;
if (G_UNLIKELY (gst_bin_type == 0)) {
static const GTypeInfo bin_info = {
sizeof (GstBinClass),
gst_bin_base_init,
NULL,
(GClassInitFunc) gst_bin_class_init,
NULL,
NULL,
sizeof (GstBin),
0,
(GInstanceInitFunc) gst_bin_init,
NULL
};
static const GInterfaceInfo child_proxy_info = {
gst_bin_child_proxy_init,
NULL,
NULL
};
gst_bin_type =
g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0);
g_type_add_interface_static (gst_bin_type, GST_TYPE_CHILD_PROXY,
&child_proxy_info);
GST_DEBUG_CATEGORY_INIT (bin_debug, "bin", GST_DEBUG_BOLD,
"debugging info for the 'bin' container element");
/* compatibility stuff */
compat = g_getenv ("GST_COMPAT");
if (compat != NULL) {
if (strstr (compat, "no-live-preroll"))
enable_latency = FALSE;
else if (strstr (compat, "live-preroll"))
enable_latency = TRUE;
}
}
return gst_bin_type;
#define _do_init(type) \
{ \
const gchar *compat; \
static const GInterfaceInfo iface_info = { \
gst_bin_child_proxy_init, \
NULL, \
NULL}; \
\
g_type_add_interface_static (type, GST_TYPE_CHILD_PROXY, &iface_info); \
\
GST_DEBUG_CATEGORY_INIT (bin_debug, "bin", GST_DEBUG_BOLD, \
"debugging info for the 'bin' container element"); \
\
/* compatibility stuff */ \
compat = g_getenv ("GST_COMPAT"); \
if (compat != NULL) { \
if (strstr (compat, "no-live-preroll")) \
enable_latency = FALSE; \
else if (strstr (compat, "live-preroll")) \
enable_latency = TRUE; \
} \
}
GST_BOILERPLATE_FULL (GstBin, gst_bin, GstElement, GST_TYPE_ELEMENT, _do_init);
static void
gst_bin_base_init (gpointer g_class)
{
@ -409,8 +384,6 @@ gst_bin_class_init (GstBinClass * klass)
gstobject_class = (GstObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (GstBinPrivate));
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_bin_set_property);
@ -511,7 +484,7 @@ gst_bin_class_init (GstBinClass * klass)
}
static void
gst_bin_init (GstBin * bin)
gst_bin_init (GstBin * bin, GstBinClass * klass)
{
GstBus *bus;

View file

@ -120,8 +120,6 @@
#include "gstutils.h"
#include "gstminiobject.h"
static void gst_buffer_init (GTypeInstance * instance, gpointer g_class);
static void gst_buffer_class_init (gpointer g_class, gpointer class_data);
static void gst_buffer_finalize (GstBuffer * buffer);
static GstBuffer *_gst_buffer_copy (GstBuffer * buffer);
static GType gst_subbuffer_get_type (void);
@ -129,8 +127,6 @@ static GType gst_subbuffer_get_type (void);
static GType _gst_subbuffer_type = 0;
static GType _gst_buffer_type = 0;
static GstMiniObjectClass *parent_class = NULL;
void
_gst_buffer_initialize (void)
{
@ -141,41 +137,19 @@ _gst_buffer_initialize (void)
g_type_class_ref (gst_subbuffer_get_type ());
}
GType
gst_buffer_get_type (void)
{
if (G_UNLIKELY (_gst_buffer_type == 0)) {
static const GTypeInfo buffer_info = {
sizeof (GstBufferClass),
NULL,
NULL,
gst_buffer_class_init,
NULL,
NULL,
sizeof (GstBuffer),
0,
gst_buffer_init,
NULL
};
_gst_buffer_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
"GstBuffer", &buffer_info, 0);
}
return _gst_buffer_type;
#define _do_init \
{ \
_gst_buffer_type = g_define_type_id; \
}
G_DEFINE_TYPE_WITH_CODE (GstBuffer, gst_buffer, GST_TYPE_MINI_OBJECT, _do_init);
static void
gst_buffer_class_init (gpointer g_class, gpointer class_data)
gst_buffer_class_init (GstBufferClass * klass)
{
GstBufferClass *buffer_class = GST_BUFFER_CLASS (g_class);
parent_class = g_type_class_peek_parent (g_class);
buffer_class->mini_object_class.copy =
(GstMiniObjectCopyFunction) _gst_buffer_copy;
buffer_class->mini_object_class.finalize =
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_buffer_copy;
klass->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_buffer_finalize;
}
static void
@ -191,7 +165,8 @@ gst_buffer_finalize (GstBuffer * buffer)
gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL);
parent_class->finalize (GST_MINI_OBJECT_CAST (buffer));
GST_MINI_OBJECT_CLASS (gst_buffer_parent_class)->finalize
(GST_MINI_OBJECT_CAST (buffer));
}
/**
@ -268,12 +243,8 @@ _gst_buffer_copy (GstBuffer * buffer)
}
static void
gst_buffer_init (GTypeInstance * instance, gpointer g_class)
gst_buffer_init (GstBuffer * buffer)
{
GstBuffer *buffer;
buffer = (GstBuffer *) instance;
GST_CAT_LOG (GST_CAT_BUFFER, "init %p", buffer);
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
@ -490,43 +461,20 @@ struct _GstSubBufferClass
GstBufferClass buffer_class;
};
static GstBufferClass *sub_parent_class;
static void gst_subbuffer_init (GTypeInstance * instance, gpointer g_class);
static void gst_subbuffer_class_init (gpointer g_class, gpointer class_data);
static void gst_subbuffer_finalize (GstSubBuffer * buffer);
static GType
gst_subbuffer_get_type (void)
{
if (G_UNLIKELY (_gst_subbuffer_type == 0)) {
static const GTypeInfo subbuffer_info = {
sizeof (GstSubBufferClass),
NULL,
NULL,
gst_subbuffer_class_init,
NULL,
NULL,
sizeof (GstSubBuffer),
0,
gst_subbuffer_init,
NULL
};
_gst_subbuffer_type = g_type_register_static (GST_TYPE_BUFFER,
"GstSubBuffer", &subbuffer_info, 0);
}
return _gst_subbuffer_type;
#define _do_init_sub \
{ \
_gst_subbuffer_type = g_define_type_id; \
}
G_DEFINE_TYPE_WITH_CODE (GstSubBuffer, gst_subbuffer, GST_TYPE_BUFFER,
_do_init_sub);
static void
gst_subbuffer_class_init (gpointer g_class, gpointer class_data)
gst_subbuffer_class_init (GstSubBufferClass * klass)
{
GstBufferClass *buffer_class = GST_BUFFER_CLASS (g_class);
sub_parent_class = g_type_class_peek_parent (g_class);
buffer_class->mini_object_class.finalize =
klass->buffer_class.mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_subbuffer_finalize;
}
@ -535,12 +483,12 @@ gst_subbuffer_finalize (GstSubBuffer * buffer)
{
gst_buffer_unref (buffer->parent);
GST_MINI_OBJECT_CLASS (sub_parent_class)->
finalize (GST_MINI_OBJECT_CAST (buffer));
GST_MINI_OBJECT_CLASS (gst_subbuffer_parent_class)->finalize
(GST_MINI_OBJECT_CAST (buffer));
}
static void
gst_subbuffer_init (GTypeInstance * instance, gpointer g_class)
gst_subbuffer_init (GstSubBuffer * instance)
{
GST_BUFFER_FLAG_SET (GST_BUFFER_CAST (instance), GST_BUFFER_FLAG_READONLY);
}

View file

@ -479,9 +479,10 @@ gst_child_proxy_base_init (gpointer g_class)
GType
gst_child_proxy_get_type (void)
{
static GType type = 0;
static volatile gsize type = 0;
if (G_UNLIKELY (type == 0)) {
if (g_once_init_enter (&type)) {
GType _type;
static const GTypeInfo info = {
sizeof (GstChildProxyInterface),
gst_child_proxy_base_init, /* base_init */
@ -493,9 +494,12 @@ gst_child_proxy_get_type (void)
0, /* n_preallocs */
NULL /* instance_init */
};
type = g_type_register_static (G_TYPE_INTERFACE, "GstChildProxy", &info, 0);
g_type_interface_add_prerequisite (type, GST_TYPE_OBJECT);
_type =
g_type_register_static (G_TYPE_INTERFACE, "GstChildProxy", &info, 0);
g_type_interface_add_prerequisite (_type, GST_TYPE_OBJECT);
g_once_init_leave (&type, (gsize) _type);
}
return type;
}

View file

@ -148,9 +148,10 @@ static guint gst_element_signals[LAST_SIGNAL] = { 0 };
GType
gst_element_get_type (void)
{
static GType gst_element_type = 0;
static volatile gsize gst_element_type = 0;
if (G_UNLIKELY (gst_element_type == 0)) {
if (g_once_init_enter (&gst_element_type)) {
GType _type;
static const GTypeInfo element_info = {
sizeof (GstElementClass),
gst_element_base_class_init,
@ -164,8 +165,9 @@ gst_element_get_type (void)
NULL
};
gst_element_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement",
_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement",
&element_info, G_TYPE_FLAG_ABSTRACT);
g_once_init_leave (&gst_element_type, _type);
}
return gst_element_type;
}

View file

@ -79,39 +79,20 @@ static GstPluginFeatureClass *parent_class = NULL;
/* static guint gst_element_factory_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_element_factory_get_type (void)
{
static GType elementfactory_type = 0;
if (G_UNLIKELY (elementfactory_type == 0)) {
static const GTypeInfo elementfactory_info = {
sizeof (GstElementFactoryClass),
NULL,
NULL,
(GClassInitFunc) gst_element_factory_class_init,
NULL,
NULL,
sizeof (GstElementFactory),
0,
(GInstanceInitFunc) gst_element_factory_init,
NULL
};
elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstElementFactory", &elementfactory_info, 0);
GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY",
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED,
"element factories keep information about installed elements");
}
return elementfactory_type;
#define _do_init \
{ \
GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY", \
GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, \
"element factories keep information about installed elements"); \
}
G_DEFINE_TYPE_WITH_CODE (GstElementFactory, gst_element_factory,
GST_TYPE_PLUGIN_FEATURE, _do_init);
static void
gst_element_factory_class_init (GstElementFactoryClass * klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
GObjectClass *gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);

View file

@ -87,8 +87,6 @@
#define GST_EVENT_SEQNUM(e) ((GstEvent*)e)->abidata.seqnum
static void gst_event_init (GTypeInstance * instance, gpointer g_class);
static void gst_event_class_init (gpointer g_class, gpointer class_data);
static void gst_event_finalize (GstEvent * event);
static GstEvent *_gst_event_copy (GstEvent * event);
@ -188,57 +186,30 @@ gst_event_type_get_flags (GstEventType type)
return ret;
}
GType
gst_event_get_type (void)
{
static GType _gst_event_type = 0;
int i;
if (G_UNLIKELY (_gst_event_type == 0)) {
static const GTypeInfo event_info = {
sizeof (GstEventClass),
NULL,
NULL,
gst_event_class_init,
NULL,
NULL,
sizeof (GstEvent),
0,
gst_event_init,
NULL
};
_gst_event_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
"GstEvent", &event_info, 0);
for (i = 0; event_quarks[i].name; i++) {
event_quarks[i].quark = g_quark_from_static_string (event_quarks[i].name);
}
}
return _gst_event_type;
#define _do_init \
{ \
gint i; \
\
for (i = 0; event_quarks[i].name; i++) { \
event_quarks[i].quark = g_quark_from_static_string (event_quarks[i].name); \
} \
}
G_DEFINE_TYPE_WITH_CODE (GstEvent, gst_event, GST_TYPE_MINI_OBJECT, _do_init);
static void
gst_event_class_init (gpointer g_class, gpointer class_data)
gst_event_class_init (GstEventClass * klass)
{
GstEventClass *event_class = GST_EVENT_CLASS (g_class);
parent_class = g_type_class_peek_parent (klass);
parent_class = g_type_class_peek_parent (g_class);
event_class->mini_object_class.copy =
(GstMiniObjectCopyFunction) _gst_event_copy;
event_class->mini_object_class.finalize =
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
klass->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_event_finalize;
}
static void
gst_event_init (GTypeInstance * instance, gpointer g_class)
gst_event_init (GstEvent * event)
{
GstEvent *event;
event = GST_EVENT (instance);
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
}

View file

@ -124,41 +124,18 @@ gst_index_entry_get_type (void)
return index_entry_type;
}
GType
gst_index_get_type (void)
{
static GType index_type = 0;
if (!index_type) {
static const GTypeInfo index_info = {
sizeof (GstIndexClass),
NULL,
NULL,
(GClassInitFunc) gst_index_class_init,
NULL,
NULL,
sizeof (GstIndex),
0,
(GInstanceInitFunc) gst_index_init,
NULL
};
index_type =
g_type_register_static (GST_TYPE_OBJECT, "GstIndex", &index_info, 0);
GST_DEBUG_CATEGORY_INIT (index_debug, "GST_INDEX", GST_DEBUG_BOLD,
"Generic indexing support");
}
return index_type;
#define _do_init \
{ \
GST_DEBUG_CATEGORY_INIT (index_debug, "GST_INDEX", GST_DEBUG_BOLD, \
"Generic indexing support"); \
}
G_DEFINE_TYPE_WITH_CODE (GstIndex, gst_index, GST_TYPE_OBJECT, _do_init);
static void
gst_index_class_init (GstIndexClass * klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);

View file

@ -43,44 +43,23 @@ static void gst_index_factory_finalize (GObject * object);
static GstPluginFeatureClass *factory_parent_class = NULL;
/* static guint gst_index_factory_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_index_factory_get_type (void)
{
static GType indexfactory_type = 0;
if (G_UNLIKELY (indexfactory_type == 0)) {
static const GTypeInfo indexfactory_info = {
sizeof (GstIndexFactoryClass),
NULL,
NULL,
(GClassInitFunc) gst_index_factory_class_init,
NULL,
NULL,
sizeof (GstIndexFactory),
0,
NULL,
NULL
};
indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstIndexFactory", &indexfactory_info, 0);
}
return indexfactory_type;
}
G_DEFINE_TYPE (GstIndexFactory, gst_index_factory, GST_TYPE_PLUGIN_FEATURE);
static void
gst_index_factory_class_init (GstIndexFactoryClass * klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
GObjectClass *gobject_class = (GObjectClass *) klass;
factory_parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_index_factory_finalize);
}
static void
gst_index_factory_init (GstIndexFactory * factory)
{
}
static void
gst_index_factory_finalize (GObject * object)
{

View file

@ -47,9 +47,10 @@ gst_implements_interface_supported_default (GstImplementsInterface * iface,
GType
gst_implements_interface_get_type (void)
{
static GType gst_interface_type = 0;
static volatile gsize gst_interface_type = 0;
if (!gst_interface_type) {
if (g_once_init_enter (&gst_interface_type)) {
GType _type;
static const GTypeInfo gst_interface_info = {
sizeof (GstImplementsInterfaceClass),
(GBaseInitFunc) gst_implements_interface_class_init,
@ -63,10 +64,11 @@ gst_implements_interface_get_type (void)
NULL
};
gst_interface_type = g_type_register_static (G_TYPE_INTERFACE,
_type = g_type_register_static (G_TYPE_INTERFACE,
"GstImplementsInterface", &gst_interface_info, 0);
g_type_interface_add_prerequisite (gst_interface_type, GST_TYPE_ELEMENT);
g_type_interface_add_prerequisite (_type, GST_TYPE_ELEMENT);
g_once_init_leave (&gst_interface_type, _type);
}
return gst_interface_type;

View file

@ -62,8 +62,6 @@
#define GST_MESSAGE_SEQNUM(e) ((GstMessage*)e)->abidata.ABI.seqnum
static void gst_message_init (GTypeInstance * instance, gpointer g_class);
static void gst_message_class_init (gpointer g_class, gpointer class_data);
static void gst_message_finalize (GstMessage * message);
static GstMessage *_gst_message_copy (GstMessage * message);
@ -155,55 +153,32 @@ gst_message_type_to_quark (GstMessageType type)
return 0;
}
GType
gst_message_get_type (void)
{
static GType _gst_message_type;
if (G_UNLIKELY (_gst_message_type == 0)) {
gint i;
static const GTypeInfo message_info = {
sizeof (GstMessageClass),
NULL,
NULL,
gst_message_class_init,
NULL,
NULL,
sizeof (GstMessage),
0,
gst_message_init,
NULL
};
_gst_message_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
"GstMessage", &message_info, 0);
for (i = 0; message_quarks[i].name; i++) {
message_quarks[i].quark =
g_quark_from_static_string (message_quarks[i].name);
}
}
return _gst_message_type;
#define _do_init \
{ \
gint i; \
\
for (i = 0; message_quarks[i].name; i++) { \
message_quarks[i].quark = \
g_quark_from_static_string (message_quarks[i].name); \
} \
}
G_DEFINE_TYPE_WITH_CODE (GstMessage, gst_message, GST_TYPE_MINI_OBJECT,
_do_init);
static void
gst_message_class_init (gpointer g_class, gpointer class_data)
gst_message_class_init (GstMessageClass * klass)
{
GstMessageClass *message_class = GST_MESSAGE_CLASS (g_class);
parent_class = g_type_class_peek_parent (klass);
parent_class = g_type_class_peek_parent (g_class);
message_class->mini_object_class.copy =
(GstMiniObjectCopyFunction) _gst_message_copy;
message_class->mini_object_class.finalize =
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_message_copy;
klass->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_message_finalize;
}
static void
gst_message_init (GTypeInstance * instance, gpointer g_class)
gst_message_init (GstMessage * message)
{
GstMessage *message = GST_MESSAGE (instance);
GST_CAT_LOG (GST_CAT_MESSAGE, "new message %p", message);
GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
}

View file

@ -140,9 +140,6 @@ static void gst_signal_object_init (GstSignalObject * object);
static guint gst_signal_object_signals[SO_LAST_SIGNAL] = { 0 };
#endif
static void gst_object_class_init (GstObjectClass * klass);
static void gst_object_init (GTypeInstance * instance, gpointer g_class);
static void gst_object_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_object_get_property (GObject * object, guint prop_id,
@ -163,38 +160,12 @@ static void gst_object_real_restore_thyself (GstObject * object,
static GObjectClass *parent_class = NULL;
static guint gst_object_signals[LAST_SIGNAL] = { 0 };
GType
gst_object_get_type (void)
{
static GType gst_object_type = 0;
if (G_UNLIKELY (gst_object_type == 0)) {
static const GTypeInfo object_info = {
sizeof (GstObjectClass),
NULL,
NULL,
(GClassInitFunc) gst_object_class_init,
NULL,
NULL,
sizeof (GstObject),
0,
gst_object_init,
NULL
};
gst_object_type =
g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info,
G_TYPE_FLAG_ABSTRACT);
}
return gst_object_type;
}
G_DEFINE_ABSTRACT_TYPE (GstObject, gst_object, G_TYPE_OBJECT);
static void
gst_object_class_init (GstObjectClass * klass)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -286,10 +257,8 @@ gst_object_class_init (GstObjectClass * klass)
}
static void
gst_object_init (GTypeInstance * instance, gpointer g_class)
gst_object_init (GstObject * object)
{
GstObject *object = GST_OBJECT (instance);
object->lock = g_mutex_new ();
object->parent = NULL;
object->name = NULL;
@ -1143,31 +1112,7 @@ struct _GstSignalObjectClass
#endif
};
static GType
gst_signal_object_get_type (void)
{
static GType signal_object_type = 0;
if (G_UNLIKELY (signal_object_type == 0)) {
static const GTypeInfo signal_object_info = {
sizeof (GstSignalObjectClass),
NULL,
NULL,
(GClassInitFunc) gst_signal_object_class_init,
NULL,
NULL,
sizeof (GstSignalObject),
0,
(GInstanceInitFunc) gst_signal_object_init,
NULL
};
signal_object_type =
g_type_register_static (G_TYPE_OBJECT, "GstSignalObject",
&signal_object_info, 0);
}
return signal_object_type;
}
G_DEFINE_TYPE (GstSignalObject, gst_signal_object, G_TYPE_OBJECT);
static void
gst_signal_object_class_init (GstSignalObjectClass * klass)

View file

@ -95,8 +95,6 @@ enum
/* FILL ME */
};
static void gst_pad_class_init (GstPadClass * klass);
static void gst_pad_init (GstPad * pad);
static void gst_pad_dispose (GObject * object);
static void gst_pad_finalize (GObject * object);
static void gst_pad_set_property (GObject * object, guint prop_id,
@ -188,37 +186,23 @@ gst_flow_to_quark (GstFlowReturn ret)
return 0;
}
GType
gst_pad_get_type (void)
{
static GType gst_pad_type = 0;
if (G_UNLIKELY (gst_pad_type == 0)) {
static const GTypeInfo pad_info = {
sizeof (GstPadClass), NULL, NULL,
(GClassInitFunc) gst_pad_class_init, NULL, NULL,
sizeof (GstPad),
0,
(GInstanceInitFunc) gst_pad_init, NULL
};
gint i;
gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad",
&pad_info, 0);
buffer_quark = g_quark_from_static_string ("buffer");
event_quark = g_quark_from_static_string ("event");
for (i = 0; flow_quarks[i].name; i++) {
flow_quarks[i].quark = g_quark_from_static_string (flow_quarks[i].name);
}
GST_DEBUG_CATEGORY_INIT (debug_dataflow, "GST_DATAFLOW",
GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, "dataflow inside pads");
}
return gst_pad_type;
#define _do_init \
{ \
gint i; \
\
buffer_quark = g_quark_from_static_string ("buffer"); \
event_quark = g_quark_from_static_string ("event"); \
\
for (i = 0; flow_quarks[i].name; i++) { \
flow_quarks[i].quark = g_quark_from_static_string (flow_quarks[i].name); \
} \
\
GST_DEBUG_CATEGORY_INIT (debug_dataflow, "GST_DATAFLOW", \
GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, "dataflow inside pads"); \
}
G_DEFINE_TYPE_WITH_CODE (GstPad, gst_pad, GST_TYPE_OBJECT, _do_init);
static gboolean
_gst_do_pass_data_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)

View file

@ -126,35 +126,13 @@ enum
static GstObject *parent_class = NULL;
static guint gst_pad_template_signals[LAST_SIGNAL] = { 0 };
static void gst_pad_template_class_init (GstPadTemplateClass * klass);
static void gst_pad_template_init (GstPadTemplate * templ,
GstPadTemplateClass * klass);
static void gst_pad_template_dispose (GObject * object);
static void gst_pad_template_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_pad_template_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
GType
gst_pad_template_get_type (void)
{
static GType padtemplate_type = 0;
if (G_UNLIKELY (padtemplate_type == 0)) {
static const GTypeInfo padtemplate_info = {
sizeof (GstPadTemplateClass), NULL, NULL,
(GClassInitFunc) gst_pad_template_class_init, NULL, NULL,
sizeof (GstPadTemplate),
0,
(GInstanceInitFunc) gst_pad_template_init, NULL
};
padtemplate_type =
g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate",
&padtemplate_info, 0);
}
return padtemplate_type;
}
G_DEFINE_TYPE (GstPadTemplate, gst_pad_template, GST_TYPE_OBJECT);
static void
gst_pad_template_class_init (GstPadTemplateClass * klass)
@ -239,7 +217,7 @@ gst_pad_template_class_init (GstPadTemplateClass * klass)
}
static void
gst_pad_template_init (GstPadTemplate * templ, GstPadTemplateClass * klass)
gst_pad_template_init (GstPadTemplate * templ)
{
/* FIXME 0.11: Does anybody remember why this is here? If not, let's
* change it for 0.11 and let gst_element_class_add_pad_template() for

View file

@ -88,6 +88,7 @@
#include "gstpipeline.h"
#include "gstinfo.h"
#include "gstsystemclock.h"
#include "gstutils.h"
GST_DEBUG_CATEGORY_STATIC (pipeline_debug);
#define GST_CAT_DEFAULT pipeline_debug
@ -125,8 +126,6 @@ struct _GstPipelinePrivate
static void gst_pipeline_base_init (gpointer g_class);
static void gst_pipeline_class_init (gpointer g_class, gpointer class_data);
static void gst_pipeline_init (GTypeInstance * instance, gpointer g_class);
static void gst_pipeline_dispose (GObject * object);
static void gst_pipeline_set_property (GObject * object, guint prop_id,
@ -140,38 +139,17 @@ static GstStateChangeReturn gst_pipeline_change_state (GstElement * element,
static void gst_pipeline_handle_message (GstBin * bin, GstMessage * message);
static GstBinClass *parent_class = NULL;
/* static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_pipeline_get_type (void)
{
static GType pipeline_type = 0;
if (G_UNLIKELY (pipeline_type == 0)) {
static const GTypeInfo pipeline_info = {
sizeof (GstPipelineClass),
gst_pipeline_base_init,
NULL,
(GClassInitFunc) gst_pipeline_class_init,
NULL,
NULL,
sizeof (GstPipeline),
0,
gst_pipeline_init,
NULL
};
pipeline_type =
g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0);
GST_DEBUG_CATEGORY_INIT (pipeline_debug, "pipeline", GST_DEBUG_BOLD,
"debugging info for the 'pipeline' container element");
}
return pipeline_type;
#define _do_init(type) \
{ \
GST_DEBUG_CATEGORY_INIT (pipeline_debug, "pipeline", GST_DEBUG_BOLD, \
"debugging info for the 'pipeline' container element"); \
}
GST_BOILERPLATE_FULL (GstPipeline, gst_pipeline, GstBin, GST_TYPE_BIN,
_do_init);
static void
gst_pipeline_base_init (gpointer g_class)
{
@ -184,12 +162,11 @@ gst_pipeline_base_init (gpointer g_class)
}
static void
gst_pipeline_class_init (gpointer g_class, gpointer class_data)
gst_pipeline_class_init (GstPipelineClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
GstBinClass *gstbin_class = GST_BIN_CLASS (g_class);
GstPipelineClass *klass = GST_PIPELINE_CLASS (g_class);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
GstBinClass *gstbin_class = GST_BIN_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -239,9 +216,8 @@ gst_pipeline_class_init (gpointer g_class, gpointer class_data)
}
static void
gst_pipeline_init (GTypeInstance * instance, gpointer g_class)
gst_pipeline_init (GstPipeline * pipeline, GstPipelineClass * klass)
{
GstPipeline *pipeline = GST_PIPELINE (instance);
GstBus *bus;
pipeline->priv = GST_PIPELINE_GET_PRIVATE (pipeline);

View file

@ -1093,9 +1093,10 @@ gst_preset_base_init (gpointer g_class)
GType
gst_preset_get_type (void)
{
static GType type = 0;
static volatile gsize type = 0;
if (type == 0) {
if (g_once_init_enter (&type)) {
GType _type;
const GTypeInfo info = {
sizeof (GstPresetInterface),
(GBaseInitFunc) gst_preset_base_init, /* base_init */
@ -1107,7 +1108,8 @@ gst_preset_get_type (void)
0, /* n_preallocs */
NULL /* instance_init */
};
type = g_type_register_static (G_TYPE_INTERFACE, "GstPreset", &info, 0);
_type = g_type_register_static (G_TYPE_INTERFACE, "GstPreset", &info, 0);
g_once_init_leave (&type, _type);
}
return type;
}

View file

@ -70,7 +70,6 @@
GST_DEBUG_CATEGORY_STATIC (gst_query_debug);
#define GST_CAT_DEFAULT gst_query_debug
static void gst_query_class_init (gpointer g_class, gpointer class_data);
static void gst_query_finalize (GstQuery * query);
static GstQuery *_gst_query_copy (GstQuery * query);
@ -164,43 +163,22 @@ gst_query_type_to_quark (GstQueryType query)
return def->quark;
}
GType
gst_query_get_type (void)
G_DEFINE_TYPE (GstQuery, gst_query, GST_TYPE_MINI_OBJECT);
static void
gst_query_class_init (GstQueryClass * klass)
{
static GType _gst_query_type;
parent_class = g_type_class_peek_parent (klass);
if (G_UNLIKELY (_gst_query_type == 0)) {
static const GTypeInfo query_info = {
sizeof (GstQueryClass),
NULL,
NULL,
gst_query_class_init,
NULL,
NULL,
sizeof (GstQuery),
0,
NULL,
NULL
};
klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
klass->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_query_finalize;
_gst_query_type = g_type_register_static (GST_TYPE_MINI_OBJECT,
"GstQuery", &query_info, 0);
}
return _gst_query_type;
}
static void
gst_query_class_init (gpointer g_class, gpointer class_data)
gst_query_init (GstQuery * query)
{
GstQueryClass *query_class = GST_QUERY_CLASS (g_class);
parent_class = g_type_class_peek_parent (g_class);
query_class->mini_object_class.copy =
(GstMiniObjectCopyFunction) _gst_query_copy;
query_class->mini_object_class.finalize =
(GstMiniObjectFinalizeFunction) gst_query_finalize;
}
static void

View file

@ -101,30 +101,7 @@ static GstClockClass *parent_class = NULL;
/* static guint gst_system_clock_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_system_clock_get_type (void)
{
static GType clock_type = 0;
if (G_UNLIKELY (clock_type == 0)) {
static const GTypeInfo clock_info = {
sizeof (GstSystemClockClass),
NULL,
NULL,
(GClassInitFunc) gst_system_clock_class_init,
NULL,
NULL,
sizeof (GstSystemClock),
0,
(GInstanceInitFunc) gst_system_clock_init,
NULL
};
clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock",
&clock_info, 0);
}
return clock_type;
}
G_DEFINE_TYPE (GstSystemClock, gst_system_clock, GST_TYPE_CLOCK);
static GType
gst_clock_type_get_type (void)

View file

@ -91,9 +91,10 @@ typedef struct
GType
gst_tag_setter_get_type (void)
{
static GType tag_setter_type = 0;
static volatile gsize tag_setter_type = 0;
if (G_UNLIKELY (tag_setter_type == 0)) {
if (g_once_init_enter (&tag_setter_type)) {
GType _type;
static const GTypeInfo tag_setter_info = {
sizeof (GstTagSetterIFace), /* class_size */
NULL, /* base_init */
@ -109,12 +110,13 @@ gst_tag_setter_get_type (void)
GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0,
"interfaces for tagging");
tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter",
_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter",
&tag_setter_info, 0);
g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT);
g_type_interface_add_prerequisite (_type, GST_TYPE_ELEMENT);
gst_tag_key = g_quark_from_static_string ("GST_TAG_SETTER");
g_once_init_leave (&tag_setter_type, _type);
}
return tag_setter_type;

View file

@ -76,33 +76,13 @@ static GstObjectClass *parent_class = NULL;
static GStaticMutex pool_lock = G_STATIC_MUTEX_INIT;
GType
gst_task_get_type (void)
{
static GType _gst_task_type = 0;
if (G_UNLIKELY (_gst_task_type == 0)) {
static const GTypeInfo task_info = {
sizeof (GstTaskClass),
NULL,
NULL,
(GClassInitFunc) gst_task_class_init,
NULL,
NULL,
sizeof (GstTask),
0,
(GInstanceInitFunc) gst_task_init,
NULL
};
_gst_task_type =
g_type_register_static (GST_TYPE_OBJECT, "GstTask", &task_info, 0);
GST_DEBUG_CATEGORY_INIT (task_debug, "task", 0, "Processing tasks");
}
return _gst_task_type;
#define _do_init \
{ \
GST_DEBUG_CATEGORY_INIT (task_debug, "task", 0, "Processing tasks"); \
}
G_DEFINE_TYPE_WITH_CODE (GstTask, gst_task, GST_TYPE_OBJECT, _do_init);
static void
gst_task_class_init (GstTaskClass * klass)
{

View file

@ -89,57 +89,32 @@
GST_DEBUG_CATEGORY (type_find_debug);
#define GST_CAT_DEFAULT type_find_debug
static void gst_type_find_factory_class_init (gpointer g_class,
gpointer class_data);
static void gst_type_find_factory_init (GTypeInstance * instance,
gpointer g_class);
static void gst_type_find_factory_dispose (GObject * object);
static GstPluginFeatureClass *parent_class = NULL;
GType
gst_type_find_factory_get_type (void)
{
static GType typefind_type = 0;
if (G_UNLIKELY (typefind_type == 0)) {
static const GTypeInfo typefind_info = {
sizeof (GstTypeFindFactoryClass),
NULL,
NULL,
gst_type_find_factory_class_init,
NULL,
NULL,
sizeof (GstTypeFindFactory),
0,
gst_type_find_factory_init,
NULL
};
typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE,
"GstTypeFindFactory", &typefind_info, 0);
GST_DEBUG_CATEGORY_INIT (type_find_debug, "GST_TYPEFIND",
GST_DEBUG_FG_GREEN, "typefinding subsystem");
}
return typefind_type;
#define _do_init \
{ \
GST_DEBUG_CATEGORY_INIT (type_find_debug, "GST_TYPEFIND", \
GST_DEBUG_FG_GREEN, "typefinding subsystem"); \
}
static void
gst_type_find_factory_class_init (gpointer g_class, gpointer class_data)
{
GObjectClass *object_class = G_OBJECT_CLASS (g_class);
G_DEFINE_TYPE_WITH_CODE (GstTypeFindFactory, gst_type_find_factory,
GST_TYPE_PLUGIN_FEATURE, _do_init);
parent_class = g_type_class_peek_parent (g_class);
static void
gst_type_find_factory_class_init (GstTypeFindFactoryClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->dispose = gst_type_find_factory_dispose;
}
static void
gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class)
gst_type_find_factory_init (GstTypeFindFactory * factory)
{
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance);
factory->user_data = factory;
factory->user_data_notify = NULL;
}

View file

@ -56,9 +56,10 @@ static void gst_uri_handler_base_init (gpointer g_class);
GType
gst_uri_handler_get_type (void)
{
static GType urihandler_type = 0;
static volatile gsize urihandler_type = 0;
if (G_UNLIKELY (urihandler_type == 0)) {
if (g_once_init_enter (&urihandler_type)) {
GType _type;
static const GTypeInfo urihandler_info = {
sizeof (GstURIHandlerInterface),
gst_uri_handler_base_init,
@ -72,14 +73,16 @@ gst_uri_handler_get_type (void)
NULL
};
urihandler_type = g_type_register_static (G_TYPE_INTERFACE,
_type = g_type_register_static (G_TYPE_INTERFACE,
"GstURIHandler", &urihandler_info, 0);
GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD,
"handling of URIs");
g_once_init_leave (&urihandler_type, _type);
}
return urihandler_type;
}
static void
gst_uri_handler_base_init (gpointer g_class)
{

View file

@ -57,36 +57,12 @@ static void gst_xml_object_loaded (GstObject * private, GstObject * object,
static GstObjectClass *parent_class = NULL;
static guint gst_xml_signals[LAST_SIGNAL] = { 0 };
GType
gst_xml_get_type (void)
{
static GType xml_type = 0;
if (G_UNLIKELY (xml_type == 0)) {
static const GTypeInfo xml_info = {
sizeof (GstXMLClass),
NULL,
NULL,
(GClassInitFunc) gst_xml_class_init,
NULL,
NULL,
sizeof (GstXML),
0,
(GInstanceInitFunc) gst_xml_init,
NULL
};
xml_type = g_type_register_static (GST_TYPE_OBJECT, "GstXML", &xml_info, 0);
}
return xml_type;
}
G_DEFINE_TYPE (GstXML, gst_xml, GST_TYPE_OBJECT);
static void
gst_xml_class_init (GstXMLClass * klass)
{
GObjectClass *gobject_class;
gobject_class = (GObjectClass *) klass;
GObjectClass *gobject_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);