Commit d12034ab authored by Sebastian Dröge's avatar Sebastian Dröge
Browse files

gst: Use g_once_init* or G_DEFINE_TYPE

parent e7ccf786
......@@ -275,9 +275,10 @@ static void gst_base_sink_finalize (GObject * object);
GType
gst_base_sink_get_type (void)
{
static GType base_sink_type = 0;
static volatile gsize base_sink_type = 0;
if (G_UNLIKELY (base_sink_type == 0)) {
if (g_once_init_enter (&base_sink_type)) {
GType _type;
static const GTypeInfo base_sink_info = {
sizeof (GstBaseSinkClass),
NULL,
......@@ -290,8 +291,9 @@ gst_base_sink_get_type (void)
(GInstanceInitFunc) gst_base_sink_init,
};
base_sink_type = g_type_register_static (GST_TYPE_ELEMENT,
_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstBaseSink", &base_sink_info, G_TYPE_FLAG_ABSTRACT);
g_once_init_leave (&base_sink_type, _type);
}
return base_sink_type;
}
......
......@@ -245,9 +245,10 @@ static void gst_base_src_finalize (GObject * object);
GType
gst_base_src_get_type (void)
{
static GType base_src_type = 0;
static volatile gsize base_src_type = 0;
if (G_UNLIKELY (base_src_type == 0)) {
if (g_once_init_enter (&base_src_type)) {
GType _type;
static const GTypeInfo base_src_info = {
sizeof (GstBaseSrcClass),
(GBaseInitFunc) gst_base_src_base_init,
......@@ -260,8 +261,9 @@ gst_base_src_get_type (void)
(GInstanceInitFunc) gst_base_src_init,
};
base_src_type = g_type_register_static (GST_TYPE_ELEMENT,
_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstBaseSrc", &base_src_info, G_TYPE_FLAG_ABSTRACT);
g_once_init_leave (&base_src_type, _type);
}
return base_src_type;
}
......
......@@ -267,9 +267,10 @@ static GstFlowReturn gst_base_transform_prepare_output_buffer (GstBaseTransform
GType
gst_base_transform_get_type (void)
{
static GType base_transform_type = 0;
static volatile gsize base_transform_type = 0;
if (!base_transform_type) {
if (g_once_init_enter (&base_transform_type)) {
GType _type;
static const GTypeInfo base_transform_info = {
sizeof (GstBaseTransformClass),
NULL,
......@@ -282,8 +283,9 @@ gst_base_transform_get_type (void)
(GInstanceInitFunc) gst_base_transform_init,
};
base_transform_type = g_type_register_static (GST_TYPE_ELEMENT,
_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstBaseTransform", &base_transform_info, G_TYPE_FLAG_ABSTRACT);
g_once_init_leave (&base_transform_type, _type);
}
return base_transform_type;
}
......
......@@ -87,8 +87,6 @@ enum
q->cur_level.time, \
q->queue->length)
static void gst_data_queue_class_init (GstDataQueueClass * klass);
static void gst_data_queue_init (GstDataQueue * queue);
static void gst_data_queue_finalize (GObject * object);
static void gst_data_queue_set_property (GObject * object,
......@@ -99,36 +97,17 @@ static void gst_data_queue_get_property (GObject * object,
static GObjectClass *parent_class = NULL;
static guint gst_data_queue_signals[LAST_SIGNAL] = { 0 };
GType
gst_data_queue_get_type (void)
{
static GType queue_type = 0;
if (!queue_type) {
static const GTypeInfo queue_info = {
sizeof (GstDataQueueClass),
NULL,
NULL,
(GClassInitFunc) gst_data_queue_class_init,
NULL,
NULL,
sizeof (GstDataQueue),
0,
(GInstanceInitFunc) gst_data_queue_init,
NULL
};
queue_type = g_type_register_static (G_TYPE_OBJECT,
"GstDataQueue", &queue_info, 0);
GST_DEBUG_CATEGORY_INIT (data_queue_debug, "dataqueue", 0,
"data queue object");
GST_DEBUG_CATEGORY_INIT (data_queue_dataflow, "data_queue_dataflow", 0,
"dataflow inside the data queue object");
}
return queue_type;
#define _do_init \
{ \
GST_DEBUG_CATEGORY_INIT (data_queue_debug, "dataqueue", 0, \
"data queue object"); \
GST_DEBUG_CATEGORY_INIT (data_queue_dataflow, "data_queue_dataflow", 0, \
"dataflow inside the data queue object"); \
}
G_DEFINE_TYPE_WITH_CODE (GstDataQueue, gst_data_queue, G_TYPE_OBJECT, _do_init);
static void
gst_data_queue_class_init (GstDataQueueClass * klass)
{
......
......@@ -954,9 +954,10 @@ _gst_controller_class_init (GstControllerClass * klass)
GType
gst_controller_get_type (void)
{
static GType type = 0;
static volatile gsize type = 0;
if (type == 0) {
if (g_once_init_enter (&type)) {
GType _type;
static const GTypeInfo info = {
sizeof (GstControllerClass),
NULL, /* base_init */
......@@ -969,7 +970,8 @@ gst_controller_get_type (void)
(GInstanceInitFunc) _gst_controller_init, /* instance_init */
NULL /* value_table */
};
type = g_type_register_static (G_TYPE_OBJECT, "GstController", &info, 0);
_type = g_type_register_static (G_TYPE_OBJECT, "GstController", &info, 0);
g_once_init_leave (&type, _type);
}
return 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