static void
gst_buffer_init (GstBufferImpl * buffer, gsize size)
{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (buffer), _gst_buffer_type);
-
- buffer->buffer.mini_object.copy =
- (GstMiniObjectCopyFunction) _gst_buffer_copy;
- buffer->buffer.mini_object.dispose =
- (GstMiniObjectDisposeFunction) _gst_buffer_dispose;
- buffer->buffer.mini_object.free =
- (GstMiniObjectFreeFunction) _gst_buffer_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (buffer), _gst_buffer_type,
+ (GstMiniObjectCopyFunction) _gst_buffer_copy,
+ (GstMiniObjectDisposeFunction) _gst_buffer_dispose,
+ (GstMiniObjectFreeFunction) _gst_buffer_free);
GST_BUFFER_SLICE_SIZE (buffer) = size;
static void
gst_buffer_list_init (GstBufferList * list, guint asize)
{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (list), _gst_buffer_list_type);
-
- list->mini_object.copy = (GstMiniObjectCopyFunction) _gst_buffer_list_copy;
- list->mini_object.free = (GstMiniObjectFreeFunction) _gst_buffer_list_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (list), _gst_buffer_list_type,
+ (GstMiniObjectCopyFunction) _gst_buffer_list_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_buffer_list_free);
list->array = g_array_sized_new (FALSE, FALSE, sizeof (GstBuffer *), asize);
static void
gst_caps_init (GstCaps * caps)
{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (caps), _gst_caps_type);
-
- caps->mini_object.copy = (GstMiniObjectCopyFunction) _gst_caps_copy;
- caps->mini_object.dispose = NULL;
- caps->mini_object.free = (GstMiniObjectFreeFunction) _gst_caps_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (caps), _gst_caps_type,
+ (GstMiniObjectCopyFunction) _gst_caps_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_caps_free);
/* the 32 has been determined by logging caps sizes in _gst_caps_free
* but g_ptr_array uses 16 anyway if it expands once, so this does not help
static void
gst_event_init (GstEventImpl * event, GstEventType type)
{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (event), _gst_event_type);
-
- event->event.mini_object.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
- event->event.mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (event), _gst_event_type,
+ (GstMiniObjectCopyFunction) _gst_event_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_event_free);
GST_EVENT_TYPE (event) = type;
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
gsize maxsize, gsize offset, gsize size, gsize align,
gpointer user_data, GDestroyNotify notify)
{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (mem), GST_TYPE_MEMORY);
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (mem), GST_TYPE_MEMORY,
+ (GstMiniObjectCopyFunction) _gst_memory_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_memory_free);
- mem->mem.mini_object.copy = (GstMiniObjectCopyFunction) _gst_memory_copy;
- mem->mem.mini_object.dispose = NULL;
- mem->mem.mini_object.free = (GstMiniObjectFreeFunction) _gst_memory_free;
mem->mem.mini_object.flags = flags;
mem->mem.allocator = _default_mem_impl;
allocator = g_slice_new0 (GstAllocator);
- gst_mini_object_init (GST_MINI_OBJECT_CAST (allocator), GST_TYPE_ALLOCATOR);
-
- allocator->mini_object.copy = (GstMiniObjectCopyFunction) _gst_allocator_copy;
- allocator->mini_object.free = (GstMiniObjectFreeFunction) _gst_allocator_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (allocator), GST_TYPE_ALLOCATOR,
+ (GstMiniObjectCopyFunction) _gst_allocator_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_allocator_free);
allocator->info = *info;
allocator->user_data = user_data;
gst_message_init (GstMessageImpl * message, GstMessageType type,
GstObject * src)
{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (message), _gst_message_type);
-
- message->message.mini_object.copy =
- (GstMiniObjectCopyFunction) _gst_message_copy;
- message->message.mini_object.free =
- (GstMiniObjectFreeFunction) _gst_message_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (message), _gst_message_type,
+ (GstMiniObjectCopyFunction) _gst_message_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_message_free);
GST_MESSAGE_TYPE (message) = type;
if (src)
}
/**
- * gst_mini_object_init:
+ * gst_mini_object_init: (skip)
* @mini_object: a #GstMiniObject
* @type: the #GType of the mini-object to create
+ * @copy_func: the copy function, or NULL
+ * @dispose_func: the dispose function, or NULL
+ * @free_func: the free function or NULL
*
- * Initializes a mini-object with the desired type and size.
+ * Initializes a mini-object with the desired type and copy/dispose/free
+ * functions.
*
* MT safe
*
* Returns: (transfer full): the new mini-object.
*/
void
-gst_mini_object_init (GstMiniObject * mini_object, GType type)
+gst_mini_object_init (GstMiniObject * mini_object, GType type,
+ GstMiniObjectCopyFunction copy_func,
+ GstMiniObjectDisposeFunction dispose_func,
+ GstMiniObjectFreeFunction free_func)
{
mini_object->type = type;
mini_object->refcount = 1;
mini_object->flags = 0;
+
+ mini_object->copy = copy_func;
+ mini_object->dispose = dispose_func;
+ mini_object->free = free_func;
+
mini_object->n_qdata = 0;
mini_object->qdata = NULL;
gpointer qdata;
};
-void gst_mini_object_init (GstMiniObject *mini_object, GType type);
+void gst_mini_object_init (GstMiniObject *mini_object, GType type,
+ GstMiniObjectCopyFunction copy_func,
+ GstMiniObjectDisposeFunction dispose_func,
+ GstMiniObjectFreeFunction free_func);
GstMiniObject * gst_mini_object_copy (const GstMiniObject *mini_object) G_GNUC_MALLOC;
gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object);
return copy;
}
-static void
-gst_query_init (GstQueryImpl * query, GstQueryType type)
-{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (query), _gst_query_type);
-
- query->query.mini_object.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
- query->query.mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
-
- GST_QUERY_TYPE (query) = type;
-}
-
/**
* gst_query_new_position:
* @format: the default #GstFormat for the new query
&query->query.mini_object.refcount))
goto had_parent;
}
- gst_query_init (query, type);
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (query), _gst_query_type,
+ (GstMiniObjectCopyFunction) _gst_query_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_query_free);
+
+ GST_QUERY_TYPE (query) = type;
GST_QUERY_STRUCTURE (query) = structure;
return GST_QUERY_CAST (query);
GST_LOG ("new %p", sample);
- gst_mini_object_init (GST_MINI_OBJECT_CAST (sample), _gst_sample_type);
-
- sample->mini_object.copy = (GstMiniObjectCopyFunction) _gst_sample_copy;
- sample->mini_object.free = (GstMiniObjectFreeFunction) _gst_sample_free;
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (sample), _gst_sample_type,
+ (GstMiniObjectCopyFunction) _gst_sample_copy, NULL,
+ (GstMiniObjectFreeFunction) _gst_sample_free);
sample->buffer = buffer ? gst_buffer_ref (buffer) : NULL;
sample->caps = caps ? gst_caps_ref (caps) : NULL;
return info->merge_func == NULL;
}
-static void
-gst_tag_list_init (GstTagList * taglist)
-{
- gst_mini_object_init (GST_MINI_OBJECT_CAST (taglist),
- gst_tag_list_get_type ());
-
- taglist->mini_object.copy = (GstMiniObjectCopyFunction) __gst_tag_list_copy;
- taglist->mini_object.dispose = NULL;
- taglist->mini_object.free = (GstMiniObjectFreeFunction) __gst_tag_list_free;
-}
-
/* takes ownership of the structure */
static GstTagList *
gst_tag_list_new_internal (GstStructure * s)
tag_list = (GstTagList *) g_slice_new (GstTagListImpl);
- gst_tag_list_init (tag_list);
+ gst_mini_object_init (GST_MINI_OBJECT_CAST (tag_list), GST_TYPE_TAG_LIST,
+ (GstMiniObjectCopyFunction) __gst_tag_list_copy, NULL,
+ (GstMiniObjectFreeFunction) __gst_tag_list_free);
GST_TAG_LIST_STRUCTURE (tag_list) = s;