mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
gst: Use g_once_init* or G_DEFINE_TYPE
This commit is contained in:
parent
e7ccf786c3
commit
d12034ab4b
5 changed files with 29 additions and 42 deletions
|
@ -275,9 +275,10 @@ static void gst_base_sink_finalize (GObject * object);
|
||||||
GType
|
GType
|
||||||
gst_base_sink_get_type (void)
|
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 = {
|
static const GTypeInfo base_sink_info = {
|
||||||
sizeof (GstBaseSinkClass),
|
sizeof (GstBaseSinkClass),
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -290,8 +291,9 @@ gst_base_sink_get_type (void)
|
||||||
(GInstanceInitFunc) gst_base_sink_init,
|
(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);
|
"GstBaseSink", &base_sink_info, G_TYPE_FLAG_ABSTRACT);
|
||||||
|
g_once_init_leave (&base_sink_type, _type);
|
||||||
}
|
}
|
||||||
return base_sink_type;
|
return base_sink_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,9 +245,10 @@ static void gst_base_src_finalize (GObject * object);
|
||||||
GType
|
GType
|
||||||
gst_base_src_get_type (void)
|
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 = {
|
static const GTypeInfo base_src_info = {
|
||||||
sizeof (GstBaseSrcClass),
|
sizeof (GstBaseSrcClass),
|
||||||
(GBaseInitFunc) gst_base_src_base_init,
|
(GBaseInitFunc) gst_base_src_base_init,
|
||||||
|
@ -260,8 +261,9 @@ gst_base_src_get_type (void)
|
||||||
(GInstanceInitFunc) gst_base_src_init,
|
(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);
|
"GstBaseSrc", &base_src_info, G_TYPE_FLAG_ABSTRACT);
|
||||||
|
g_once_init_leave (&base_src_type, _type);
|
||||||
}
|
}
|
||||||
return base_src_type;
|
return base_src_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,9 +267,10 @@ static GstFlowReturn gst_base_transform_prepare_output_buffer (GstBaseTransform
|
||||||
GType
|
GType
|
||||||
gst_base_transform_get_type (void)
|
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 = {
|
static const GTypeInfo base_transform_info = {
|
||||||
sizeof (GstBaseTransformClass),
|
sizeof (GstBaseTransformClass),
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -282,8 +283,9 @@ gst_base_transform_get_type (void)
|
||||||
(GInstanceInitFunc) gst_base_transform_init,
|
(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);
|
"GstBaseTransform", &base_transform_info, G_TYPE_FLAG_ABSTRACT);
|
||||||
|
g_once_init_leave (&base_transform_type, _type);
|
||||||
}
|
}
|
||||||
return base_transform_type;
|
return base_transform_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,6 @@ enum
|
||||||
q->cur_level.time, \
|
q->cur_level.time, \
|
||||||
q->queue->length)
|
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_finalize (GObject * object);
|
||||||
|
|
||||||
static void gst_data_queue_set_property (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 GObjectClass *parent_class = NULL;
|
||||||
static guint gst_data_queue_signals[LAST_SIGNAL] = { 0 };
|
static guint gst_data_queue_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
GType
|
#define _do_init \
|
||||||
gst_data_queue_get_type (void)
|
{ \
|
||||||
{
|
GST_DEBUG_CATEGORY_INIT (data_queue_debug, "dataqueue", 0, \
|
||||||
static GType queue_type = 0;
|
"data queue object"); \
|
||||||
|
GST_DEBUG_CATEGORY_INIT (data_queue_dataflow, "data_queue_dataflow", 0, \
|
||||||
if (!queue_type) {
|
"dataflow inside the data queue object"); \
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (GstDataQueue, gst_data_queue, G_TYPE_OBJECT, _do_init);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_data_queue_class_init (GstDataQueueClass * klass)
|
gst_data_queue_class_init (GstDataQueueClass * klass)
|
||||||
{
|
{
|
||||||
|
|
|
@ -954,9 +954,10 @@ _gst_controller_class_init (GstControllerClass * klass)
|
||||||
GType
|
GType
|
||||||
gst_controller_get_type (void)
|
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 = {
|
static const GTypeInfo info = {
|
||||||
sizeof (GstControllerClass),
|
sizeof (GstControllerClass),
|
||||||
NULL, /* base_init */
|
NULL, /* base_init */
|
||||||
|
@ -969,7 +970,8 @@ gst_controller_get_type (void)
|
||||||
(GInstanceInitFunc) _gst_controller_init, /* instance_init */
|
(GInstanceInitFunc) _gst_controller_init, /* instance_init */
|
||||||
NULL /* value_table */
|
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;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue