mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
plugins: Make *_get_type() in plugins/* thread safe
It's not really needed here but using G_DEFINE_TYPE() reduces some copy&paste boilerplate code.
This commit is contained in:
parent
27bebf7456
commit
cfefcc7183
3 changed files with 8 additions and 94 deletions
|
@ -486,52 +486,22 @@ struct _GstMmapBufferClass
|
||||||
GstBufferClass buffer_class;
|
GstBufferClass buffer_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_mmap_buffer_init (GTypeInstance * instance, gpointer g_class);
|
|
||||||
static void gst_mmap_buffer_class_init (gpointer g_class, gpointer class_data);
|
|
||||||
static void gst_mmap_buffer_finalize (GstMmapBuffer * mmap_buffer);
|
static void gst_mmap_buffer_finalize (GstMmapBuffer * mmap_buffer);
|
||||||
static GstBufferClass *mmap_buffer_parent_class = NULL;
|
|
||||||
|
|
||||||
static GType
|
G_DEFINE_TYPE (GstMmapBuffer, gst_mmap_buffer, GST_TYPE_BUFFER);
|
||||||
gst_mmap_buffer_get_type (void)
|
|
||||||
{
|
|
||||||
static GType _gst_mmap_buffer_type;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (_gst_mmap_buffer_type == 0)) {
|
|
||||||
static const GTypeInfo mmap_buffer_info = {
|
|
||||||
sizeof (GstMmapBufferClass),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
gst_mmap_buffer_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstMmapBuffer),
|
|
||||||
0,
|
|
||||||
gst_mmap_buffer_init,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
_gst_mmap_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
|
|
||||||
"GstMmapBuffer", &mmap_buffer_info, 0);
|
|
||||||
}
|
|
||||||
return _gst_mmap_buffer_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_mmap_buffer_class_init (gpointer g_class, gpointer class_data)
|
gst_mmap_buffer_class_init (GstMmapBufferClass * g_class)
|
||||||
{
|
{
|
||||||
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
|
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
|
||||||
|
|
||||||
mmap_buffer_parent_class = g_type_class_peek_parent (g_class);
|
|
||||||
|
|
||||||
mini_object_class->finalize =
|
mini_object_class->finalize =
|
||||||
(GstMiniObjectFinalizeFunction) gst_mmap_buffer_finalize;
|
(GstMiniObjectFinalizeFunction) gst_mmap_buffer_finalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_mmap_buffer_init (GTypeInstance * instance, gpointer g_class)
|
gst_mmap_buffer_init (GstMmapBuffer * buf)
|
||||||
{
|
{
|
||||||
GstBuffer *buf = (GstBuffer *) instance;
|
|
||||||
|
|
||||||
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
|
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
|
||||||
/* before we re-enable this flag, we probably need to fix _copy()
|
/* before we re-enable this flag, we probably need to fix _copy()
|
||||||
* _make_writable(), etc. in GstMiniObject/GstBuffer as well */
|
* _make_writable(), etc. in GstMiniObject/GstBuffer as well */
|
||||||
|
@ -572,8 +542,8 @@ gst_mmap_buffer_finalize (GstMmapBuffer * mmap_buffer)
|
||||||
GST_LOG ("unmapped region %08lx+%08lx at %p",
|
GST_LOG ("unmapped region %08lx+%08lx at %p",
|
||||||
(gulong) offset, (gulong) size, data);
|
(gulong) offset, (gulong) size, data);
|
||||||
|
|
||||||
GST_MINI_OBJECT_CLASS (mmap_buffer_parent_class)->finalize (GST_MINI_OBJECT
|
GST_MINI_OBJECT_CLASS (gst_mmap_buffer_parent_class)->finalize
|
||||||
(mmap_buffer));
|
(GST_MINI_OBJECT (mmap_buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
|
|
|
@ -124,8 +124,6 @@ enum
|
||||||
ARG_LOCATION,
|
ARG_LOCATION,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_file_index_class_init (GstFileIndexClass * klass);
|
|
||||||
static void gst_file_index_init (GstFileIndex * index);
|
|
||||||
static void gst_file_index_dispose (GObject * object);
|
static void gst_file_index_dispose (GObject * object);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -148,33 +146,7 @@ static GstIndexEntry *gst_file_index_get_assoc_entry (GstIndex * index, gint id,
|
||||||
|
|
||||||
#define CLASS(file_index) GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index))
|
#define CLASS(file_index) GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index))
|
||||||
|
|
||||||
static GstIndex *parent_class = NULL;
|
G_DEFINE_TYPE (GstFileIndex, gst_file_index, GST_TYPE_INDEX);
|
||||||
|
|
||||||
static GType
|
|
||||||
gst_file_index_get_type (void)
|
|
||||||
{
|
|
||||||
static GType file_index_type = 0;
|
|
||||||
|
|
||||||
if (!file_index_type) {
|
|
||||||
static const GTypeInfo file_index_info = {
|
|
||||||
sizeof (GstFileIndexClass),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_file_index_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstFileIndex),
|
|
||||||
1,
|
|
||||||
(GInstanceInitFunc) gst_file_index_init,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
file_index_type =
|
|
||||||
g_type_register_static (GST_TYPE_INDEX, "GstFileIndex",
|
|
||||||
&file_index_info, 0);
|
|
||||||
}
|
|
||||||
return file_index_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_file_index_class_init (GstFileIndexClass * klass)
|
gst_file_index_class_init (GstFileIndexClass * klass)
|
||||||
|
@ -185,8 +157,6 @@ gst_file_index_class_init (GstFileIndexClass * klass)
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
gstindex_class = (GstIndexClass *) klass;
|
gstindex_class = (GstIndexClass *) klass;
|
||||||
|
|
||||||
parent_class = g_type_class_peek_parent (klass);
|
|
||||||
|
|
||||||
gobject_class->dispose = gst_file_index_dispose;
|
gobject_class->dispose = gst_file_index_dispose;
|
||||||
gobject_class->set_property = gst_file_index_set_property;
|
gobject_class->set_property = gst_file_index_set_property;
|
||||||
gobject_class->get_property = gst_file_index_get_property;
|
gobject_class->get_property = gst_file_index_get_property;
|
||||||
|
@ -259,7 +229,7 @@ gst_file_index_dispose (GObject * object)
|
||||||
|
|
||||||
gst_index_entry_free (index->ret_entry); /* hack */
|
gst_index_entry_free (index->ret_entry); /* hack */
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (gst_file_index_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct fi_find_writer_context
|
struct fi_find_writer_context
|
||||||
|
|
|
@ -107,8 +107,6 @@ enum
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gst_mem_index_class_init (GstMemIndexClass * klass);
|
|
||||||
static void gst_mem_index_init (GstMemIndex * index);
|
|
||||||
static void gst_mem_index_finalize (GObject * object);
|
static void gst_mem_index_finalize (GObject * object);
|
||||||
|
|
||||||
static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry);
|
static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry);
|
||||||
|
@ -122,31 +120,7 @@ static GstIndex *parent_class = NULL;
|
||||||
|
|
||||||
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
|
/*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */
|
||||||
|
|
||||||
static GType
|
G_DEFINE_TYPE (GstMemIndex, gst_mem_index, GST_TYPE_INDEX);
|
||||||
gst_mem_index_get_type (void)
|
|
||||||
{
|
|
||||||
static GType mem_index_type = 0;
|
|
||||||
|
|
||||||
if (!mem_index_type) {
|
|
||||||
static const GTypeInfo mem_index_info = {
|
|
||||||
sizeof (GstMemIndexClass),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
(GClassInitFunc) gst_mem_index_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstMemIndex),
|
|
||||||
1,
|
|
||||||
(GInstanceInitFunc) gst_mem_index_init,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
mem_index_type =
|
|
||||||
g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
return mem_index_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_mem_index_class_init (GstMemIndexClass * klass)
|
gst_mem_index_class_init (GstMemIndexClass * klass)
|
||||||
|
|
Loading…
Reference in a new issue