mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
init: add _get_type() functions
Remove gst_mini_object_register() and add a GST_DEFINE_MINI_OBJECT macro to define a _get_type() function for the boxed miniobject. Remove a bunch of custom _get_type() functions and replace them with the miniobject macro. Rename some _init method to _priv_*_initialize() like the rest of them. Inspired by patch from Johan Dahlin and see bug #657603
This commit is contained in:
parent
4145598972
commit
f3b0d3cdbe
19 changed files with 41 additions and 65 deletions
|
@ -665,12 +665,12 @@ init_post (GOptionContext * context, GOptionGroup * group, gpointer data,
|
|||
g_log_set_handler (g_log_domain_gstreamer, llf, debug_log_handler, NULL);
|
||||
|
||||
_priv_gst_quarks_initialize ();
|
||||
_gst_memory_init ();
|
||||
_priv_gst_memory_initialize ();
|
||||
_priv_gst_format_initialize ();
|
||||
_priv_gst_query_initialize ();
|
||||
_priv_gst_structure_initialize ();
|
||||
_priv_gst_caps_initialize ();
|
||||
_gst_meta_init ();
|
||||
_priv_gst_meta_initialize ();
|
||||
|
||||
g_type_class_ref (gst_object_get_type ());
|
||||
g_type_class_ref (gst_pad_get_type ());
|
||||
|
|
|
@ -100,6 +100,8 @@ void _priv_gst_caps_initialize (void);
|
|||
void _priv_gst_event_initialize (void);
|
||||
void _priv_gst_format_initialize (void);
|
||||
void _priv_gst_message_initialize (void);
|
||||
void _priv_gst_memory_initialize (void);
|
||||
void _priv_gst_meta_initialize (void);
|
||||
void _priv_gst_plugin_initialize (void);
|
||||
void _priv_gst_query_initialize (void);
|
||||
void _priv_gst_tag_initialize (void);
|
||||
|
|
|
@ -223,12 +223,12 @@ _memory_add (GstBuffer * buffer, guint idx, GstMemory * mem)
|
|||
GST_BUFFER_MEM_LEN (buffer) = len + 1;
|
||||
}
|
||||
|
||||
GST_DEFINE_MINI_OBJECT (GstBuffer, gst_buffer);
|
||||
|
||||
void
|
||||
_priv_gst_buffer_initialize (void)
|
||||
{
|
||||
if (G_LIKELY (_gst_buffer_type == 0)) {
|
||||
_gst_buffer_type = gst_mini_object_register ("GstBuffer");
|
||||
}
|
||||
_gst_buffer_type = gst_buffer_get_type ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -240,6 +240,8 @@ struct _GstBuffer {
|
|||
guint64 offset_end;
|
||||
};
|
||||
|
||||
GType gst_buffer_get_type (void);
|
||||
|
||||
/* allocation */
|
||||
GstBuffer * gst_buffer_new (void);
|
||||
GstBuffer * gst_buffer_new_allocate (const GstAllocator * allocator, gsize maxsize, gsize align);
|
||||
|
|
|
@ -54,12 +54,12 @@ struct _GstBufferList
|
|||
|
||||
GType _gst_buffer_list_type = 0;
|
||||
|
||||
GST_DEFINE_MINI_OBJECT (GstBufferList, gst_buffer_list);
|
||||
|
||||
void
|
||||
_priv_gst_buffer_list_initialize (void)
|
||||
{
|
||||
if (G_LIKELY (_gst_buffer_list_type == 0)) {
|
||||
_gst_buffer_list_type = gst_mini_object_register ("GstBufferList");
|
||||
}
|
||||
_gst_buffer_list_type = gst_buffer_list_get_type ();
|
||||
}
|
||||
|
||||
static GstBufferList *
|
||||
|
|
|
@ -153,6 +153,8 @@ gst_buffer_list_copy (const GstBufferList * list)
|
|||
*/
|
||||
#define gst_buffer_list_make_writable(list) GST_BUFFER_LIST_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (list)))
|
||||
|
||||
GType gst_buffer_list_get_type (void);
|
||||
|
||||
/* allocation */
|
||||
GstBufferList * gst_buffer_list_new (void);
|
||||
GstBufferList * gst_buffer_list_sized_new (guint size);
|
||||
|
|
|
@ -115,10 +115,12 @@ static gboolean gst_caps_from_string_inplace (GstCaps * caps,
|
|||
|
||||
GType _gst_caps_type = 0;
|
||||
|
||||
GST_DEFINE_MINI_OBJECT (GstCaps, gst_caps);
|
||||
|
||||
void
|
||||
_priv_gst_caps_initialize (void)
|
||||
{
|
||||
_gst_caps_type = gst_mini_object_register ("GstCaps");
|
||||
_gst_caps_type = gst_caps_get_type ();
|
||||
|
||||
g_value_register_transform_func (_gst_caps_type,
|
||||
G_TYPE_STRING, gst_caps_transform_to_string);
|
||||
|
|
|
@ -336,6 +336,8 @@ struct _GstStaticCaps {
|
|||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GType gst_caps_get_type (void);
|
||||
|
||||
GstCaps * gst_caps_new_empty (void);
|
||||
GstCaps * gst_caps_new_any (void);
|
||||
GstCaps * gst_caps_new_simple (const char *media_type,
|
||||
|
|
|
@ -128,12 +128,14 @@ static GstEventQuarks event_quarks[] = {
|
|||
{0, NULL, 0}
|
||||
};
|
||||
|
||||
GST_DEFINE_MINI_OBJECT (GstEvent, gst_event);
|
||||
|
||||
void
|
||||
_priv_gst_event_initialize (void)
|
||||
{
|
||||
gint i;
|
||||
|
||||
_gst_event_type = gst_mini_object_register ("GstEvent");
|
||||
_gst_event_type = gst_event_get_type ();
|
||||
|
||||
g_type_class_ref (gst_seek_flags_get_type ());
|
||||
g_type_class_ref (gst_seek_type_get_type ());
|
||||
|
|
|
@ -412,6 +412,7 @@ gst_event_copy (const GstEvent * event)
|
|||
return GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (event)));
|
||||
}
|
||||
|
||||
GType gst_event_get_type (void);
|
||||
|
||||
/* custom event */
|
||||
GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure);
|
||||
|
|
|
@ -308,7 +308,7 @@ static GStaticRWLock lock = G_STATIC_RW_LOCK_INIT;
|
|||
static GHashTable *allocators;
|
||||
|
||||
void
|
||||
_gst_memory_init (void)
|
||||
_priv_gst_memory_initialize (void)
|
||||
{
|
||||
static const GstMemoryInfo _mem_info = {
|
||||
(GstMemoryAllocFunction) _default_mem_alloc,
|
||||
|
|
|
@ -264,8 +264,6 @@ struct _GstMemoryInfo {
|
|||
gpointer user_data;
|
||||
};
|
||||
|
||||
void _gst_memory_init (void);
|
||||
|
||||
/* allocators */
|
||||
const GstAllocator * gst_allocator_register (const gchar *name, const GstMemoryInfo *info);
|
||||
const GstAllocator * gst_allocator_find (const gchar *name);
|
||||
|
|
|
@ -60,8 +60,6 @@
|
|||
#include "gstquark.h"
|
||||
|
||||
|
||||
static GType _gst_message_type = 0;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GstMessage message;
|
||||
|
@ -109,6 +107,9 @@ static GstMessageQuarks message_quarks[] = {
|
|||
{0, NULL, 0}
|
||||
};
|
||||
|
||||
static GType _gst_message_type = 0;
|
||||
GST_DEFINE_MINI_OBJECT (GstMessage, gst_message);
|
||||
|
||||
void
|
||||
_priv_gst_message_initialize (void)
|
||||
{
|
||||
|
@ -125,6 +126,8 @@ _priv_gst_message_initialize (void)
|
|||
message_quarks[i].quark =
|
||||
g_quark_from_static_string (message_quarks[i].name);
|
||||
}
|
||||
|
||||
_gst_message_type = gst_message_get_type ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -167,16 +170,6 @@ gst_message_type_to_quark (GstMessageType type)
|
|||
return 0;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_message_get_type (void)
|
||||
{
|
||||
if (G_UNLIKELY (_gst_message_type == 0)) {
|
||||
_gst_message_type = gst_mini_object_register ("GstMessage");
|
||||
}
|
||||
return _gst_message_type;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_gst_message_free (GstMessage * message)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ static GHashTable *metainfo = NULL;
|
|||
static GStaticRWLock lock = G_STATIC_RW_LOCK_INIT;
|
||||
|
||||
void
|
||||
_gst_meta_init (void)
|
||||
_priv_gst_meta_initialize (void)
|
||||
{
|
||||
metainfo = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
}
|
||||
|
|
|
@ -107,8 +107,6 @@ struct _GstMetaInfo {
|
|||
GstMetaTransformFunction transform_func;
|
||||
};
|
||||
|
||||
void _gst_meta_init (void);
|
||||
|
||||
const GstMetaInfo * gst_meta_register (const gchar *api, const gchar *impl,
|
||||
gsize size,
|
||||
GstMetaInitFunction init_func,
|
||||
|
|
|
@ -48,30 +48,6 @@ static GstAllocTrace *_gst_mini_object_trace;
|
|||
/* Mutex used for weak referencing */
|
||||
G_LOCK_DEFINE_STATIC (weak_refs_mutex);
|
||||
|
||||
/**
|
||||
* gst_mini_object_register:
|
||||
* @name: name of the new boxed type
|
||||
*
|
||||
* This function creates a new G_TYPE_BOXED derived type id for a new boxed type
|
||||
* with name @name. The default miniobject refcounting copy and free function
|
||||
* are used for the boxed type.
|
||||
*
|
||||
* Returns: a new G_TYPE_BOXED derived type id for @name.
|
||||
*/
|
||||
GType
|
||||
gst_mini_object_register (const gchar * name)
|
||||
{
|
||||
GType type;
|
||||
|
||||
g_return_val_if_fail (name != NULL, 0);
|
||||
|
||||
type = g_boxed_type_register_static (name,
|
||||
(GBoxedCopyFunc) gst_mini_object_ref,
|
||||
(GBoxedFreeFunc) gst_mini_object_unref);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_mini_object_init:
|
||||
* @mini_object: a #GstMiniObject
|
||||
|
|
|
@ -193,8 +193,6 @@ struct _GstMiniObject {
|
|||
} *weak_refs;
|
||||
};
|
||||
|
||||
GType gst_mini_object_register (const gchar *name);
|
||||
|
||||
void gst_mini_object_init (GstMiniObject *mini_object,
|
||||
GType type, gsize size);
|
||||
|
||||
|
@ -217,6 +215,10 @@ gboolean gst_mini_object_replace (GstMiniObject **olddata, GstMin
|
|||
gboolean gst_mini_object_take (GstMiniObject **olddata, GstMiniObject *newdata);
|
||||
GstMiniObject * gst_mini_object_steal (GstMiniObject **olddata);
|
||||
|
||||
#define GST_DEFINE_MINI_OBJECT(TypeName,type_name) \
|
||||
G_DEFINE_BOXED_TYPE(TypeName,type_name, \
|
||||
(GBoxedCopyFunc) gst_mini_object_ref, \
|
||||
(GBoxedFreeFunc)gst_mini_object_unref)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ static GstQueryTypeDefinition standard_definitions[] = {
|
|||
{GST_QUERY_NONE, NULL, NULL, 0}
|
||||
};
|
||||
|
||||
GST_DEFINE_MINI_OBJECT (GstQuery, gst_query);
|
||||
|
||||
void
|
||||
_priv_gst_query_initialize (void)
|
||||
{
|
||||
|
@ -135,7 +137,7 @@ _priv_gst_query_initialize (void)
|
|||
}
|
||||
g_static_mutex_unlock (&mutex);
|
||||
|
||||
gst_query_get_type ();
|
||||
_gst_query_type = gst_query_get_type ();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,16 +178,6 @@ gst_query_type_to_quark (GstQueryType query)
|
|||
return def->quark;
|
||||
}
|
||||
|
||||
GType
|
||||
gst_query_get_type (void)
|
||||
{
|
||||
if (G_UNLIKELY (_gst_query_type == 0)) {
|
||||
_gst_query_type = gst_mini_object_register ("GstQuery");
|
||||
}
|
||||
return _gst_query_type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_query_type_register:
|
||||
* @nick: The nick of the new query
|
||||
|
|
|
@ -102,11 +102,13 @@ EXPORTS
|
|||
gst_buffer_flags_get_type
|
||||
gst_buffer_get_meta
|
||||
gst_buffer_get_sizes
|
||||
gst_buffer_get_type
|
||||
gst_buffer_is_span_fast
|
||||
gst_buffer_iterate_meta
|
||||
gst_buffer_join
|
||||
gst_buffer_list_foreach
|
||||
gst_buffer_list_get
|
||||
gst_buffer_list_get_type
|
||||
gst_buffer_list_insert
|
||||
gst_buffer_list_len
|
||||
gst_buffer_list_new
|
||||
|
@ -180,6 +182,7 @@ EXPORTS
|
|||
gst_caps_from_string
|
||||
gst_caps_get_size
|
||||
gst_caps_get_structure
|
||||
gst_caps_get_type
|
||||
gst_caps_intersect
|
||||
gst_caps_intersect_full
|
||||
gst_caps_intersect_mode_get_type
|
||||
|
@ -395,6 +398,7 @@ EXPORTS
|
|||
gst_event_copy_segment
|
||||
gst_event_get_seqnum
|
||||
gst_event_get_structure
|
||||
gst_event_get_type
|
||||
gst_event_has_name
|
||||
gst_event_new_buffer_size
|
||||
gst_event_new_caps
|
||||
|
|
Loading…
Reference in a new issue