mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
Use macros to register boxed types thread safely
This commit is contained in:
parent
8f8335a7f4
commit
e234a10c63
10 changed files with 24 additions and 122 deletions
|
@ -351,16 +351,7 @@ gst_caps_new_full_valist (GstStructure * structure, va_list var_args)
|
|||
return caps;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_static_caps_get_type (void)
|
||||
{
|
||||
static GType staticcaps_type = 0;
|
||||
|
||||
if (G_UNLIKELY (staticcaps_type == 0)) {
|
||||
staticcaps_type = g_pointer_type_register_static ("GstStaticCaps");
|
||||
}
|
||||
return staticcaps_type;
|
||||
}
|
||||
G_DEFINE_POINTER_TYPE (GstStaticCaps, gst_static_caps);
|
||||
|
||||
/**
|
||||
* gst_static_caps_get:
|
||||
|
|
|
@ -85,16 +85,8 @@ gst_iterator_copy (const GstIterator * it)
|
|||
return copy;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_iterator_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (type == 0))
|
||||
type = g_boxed_type_register_static ("GstIterator",
|
||||
(GBoxedCopyFunc) gst_iterator_copy, (GBoxedFreeFunc) gst_iterator_free);
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_BOXED_TYPE (GstIterator, gst_iterator,
|
||||
(GBoxedCopyFunc) gst_iterator_copy, (GBoxedFreeFunc) gst_iterator_free);
|
||||
|
||||
static void
|
||||
gst_iterator_init (GstIterator * it,
|
||||
|
|
|
@ -272,17 +272,7 @@ name_is_valid (const gchar * name, GstPadPresence presence)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_static_pad_template_get_type (void)
|
||||
{
|
||||
static GType staticpadtemplate_type = 0;
|
||||
|
||||
if (G_UNLIKELY (staticpadtemplate_type == 0)) {
|
||||
staticpadtemplate_type =
|
||||
g_pointer_type_register_static ("GstStaticPadTemplate");
|
||||
}
|
||||
return staticpadtemplate_type;
|
||||
}
|
||||
G_DEFINE_POINTER_TYPE (GstStaticPadTemplate, gst_static_pad_template);
|
||||
|
||||
/**
|
||||
* gst_static_pad_template_get:
|
||||
|
|
|
@ -64,19 +64,9 @@ gst_parse_context_copy (const GstParseContext * context)
|
|||
return ret;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_parse_context_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (G_UNLIKELY (type == 0)) {
|
||||
type = g_boxed_type_register_static ("GstParseContext",
|
||||
(GBoxedCopyFunc) gst_parse_context_copy,
|
||||
(GBoxedFreeFunc) gst_parse_context_free);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
G_DEFINE_BOXED_TYPE (GstParseContext, gst_parse_context,
|
||||
(GBoxedCopyFunc) gst_parse_context_copy,
|
||||
(GBoxedFreeFunc) gst_parse_context_free);
|
||||
|
||||
/**
|
||||
* gst_parse_error_quark:
|
||||
|
|
|
@ -113,18 +113,8 @@ gst_segment_copy_into (const GstSegment * src, GstSegment * dest)
|
|||
memcpy (dest, src, sizeof (GstSegment));
|
||||
}
|
||||
|
||||
GType
|
||||
gst_segment_get_type (void)
|
||||
{
|
||||
static GType gst_segment_type = 0;
|
||||
|
||||
if (G_UNLIKELY (gst_segment_type == 0)) {
|
||||
gst_segment_type = g_boxed_type_register_static ("GstSegment",
|
||||
(GBoxedCopyFunc) gst_segment_copy, (GBoxedFreeFunc) gst_segment_free);
|
||||
}
|
||||
|
||||
return gst_segment_type;
|
||||
}
|
||||
G_DEFINE_BOXED_TYPE (GstSegment, gst_segment,
|
||||
(GBoxedCopyFunc) gst_segment_copy, (GBoxedFreeFunc) gst_segment_free);
|
||||
|
||||
/**
|
||||
* gst_segment_new:
|
||||
|
|
|
@ -82,23 +82,13 @@ static GMutex __tag_mutex;
|
|||
/* tags hash table: maps tag name string => GstTagInfo */
|
||||
static GHashTable *__tags;
|
||||
|
||||
GType
|
||||
gst_tag_list_get_type (void)
|
||||
{
|
||||
static GType _gst_tag_list_type = 0;
|
||||
G_DEFINE_BOXED_TYPE (GstTagList, gst_tag_list,
|
||||
(GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
|
||||
|
||||
if (G_UNLIKELY (_gst_tag_list_type == 0)) {
|
||||
_gst_tag_list_type = g_boxed_type_register_static ("GstTagList",
|
||||
(GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free);
|
||||
|
||||
#if 0
|
||||
g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
|
||||
_gst_structure_transform_to_string);
|
||||
#endif
|
||||
}
|
||||
|
||||
return _gst_tag_list_type;
|
||||
}
|
||||
/* FIXME: had code:
|
||||
* g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING,
|
||||
* _gst_structure_transform_to_string);
|
||||
*/
|
||||
|
||||
void
|
||||
_priv_gst_tag_initialize (void)
|
||||
|
|
|
@ -38,16 +38,7 @@
|
|||
GST_DEBUG_CATEGORY_EXTERN (type_find_debug);
|
||||
#define GST_CAT_DEFAULT type_find_debug
|
||||
|
||||
GType
|
||||
gst_type_find_get_type (void)
|
||||
{
|
||||
static GType typefind_type = 0;
|
||||
|
||||
if (G_UNLIKELY (typefind_type == 0)) {
|
||||
typefind_type = g_pointer_type_register_static ("GstTypeFind");
|
||||
}
|
||||
return typefind_type;
|
||||
}
|
||||
G_DEFINE_POINTER_TYPE (GstTypeFind, gst_type_find);
|
||||
|
||||
/**
|
||||
* gst_type_find_register:
|
||||
|
|
|
@ -5508,19 +5508,8 @@ static const GTypeValueTable _gst_fraction_value_table = {
|
|||
|
||||
FUNC_VALUE_GET_TYPE (fraction, "GstFraction");
|
||||
|
||||
GType
|
||||
gst_date_time_get_type (void)
|
||||
{
|
||||
static GType gst_date_time_type = 0;
|
||||
|
||||
if (G_UNLIKELY (gst_date_time_type == 0)) {
|
||||
gst_date_time_type = g_boxed_type_register_static ("GstDateTime",
|
||||
(GBoxedCopyFunc) gst_date_time_ref,
|
||||
(GBoxedFreeFunc) gst_date_time_unref);
|
||||
}
|
||||
|
||||
return gst_date_time_type;
|
||||
}
|
||||
G_DEFINE_BOXED_TYPE (GstDateTime, gst_date_time,
|
||||
(GBoxedCopyFunc) gst_date_time_ref, (GBoxedFreeFunc) gst_date_time_unref);
|
||||
|
||||
static const GTypeValueTable _gst_bitmask_value_table = {
|
||||
gst_value_init_bitmask,
|
||||
|
|
|
@ -611,21 +611,9 @@ gst_base_parse_frame_free (GstBaseParseFrame * frame)
|
|||
}
|
||||
}
|
||||
|
||||
GType
|
||||
gst_base_parse_frame_get_type (void)
|
||||
{
|
||||
static volatile gsize frame_type = 0;
|
||||
|
||||
if (g_once_init_enter (&frame_type)) {
|
||||
GType _type;
|
||||
|
||||
_type = g_boxed_type_register_static ("GstBaseParseFrame",
|
||||
(GBoxedCopyFunc) gst_base_parse_frame_copy,
|
||||
(GBoxedFreeFunc) gst_base_parse_frame_free);
|
||||
g_once_init_leave (&frame_type, _type);
|
||||
}
|
||||
return (GType) frame_type;
|
||||
}
|
||||
G_DEFINE_BOXED_TYPE (GstBaseParseFrame, gst_base_parse_frame,
|
||||
(GBoxedCopyFunc) gst_base_parse_frame_copy,
|
||||
(GBoxedFreeFunc) gst_base_parse_frame_free);
|
||||
|
||||
/**
|
||||
* gst_base_parse_frame_init:
|
||||
|
|
|
@ -131,18 +131,9 @@ gst_index_resolver_get_type (void)
|
|||
return index_resolver_type;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_index_entry_get_type (void)
|
||||
{
|
||||
static GType index_entry_type = 0;
|
||||
|
||||
if (!index_entry_type) {
|
||||
index_entry_type = g_boxed_type_register_static ("GstIndexEntry",
|
||||
(GBoxedCopyFunc) gst_index_entry_copy,
|
||||
(GBoxedFreeFunc) gst_index_entry_free);
|
||||
}
|
||||
return index_entry_type;
|
||||
}
|
||||
G_DEFINE_BOXED_TYPE (GstIndexEntry, gst_index_entry,
|
||||
(GBoxedCopyFunc) gst_index_entry_copy,
|
||||
(GBoxedFreeFunc) gst_index_entry_free);
|
||||
|
||||
#if 0
|
||||
#define _do_init \
|
||||
|
|
Loading…
Reference in a new issue