mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
miniobject: remove the size field
The size field is used by subclasses to store the total allocated size of the memory for this miniobject. Because miniobject doesn't really do anything with this field we can move it to the subclasses.
This commit is contained in:
parent
a1c5b00e72
commit
12aefaa078
11 changed files with 66 additions and 43 deletions
|
@ -138,6 +138,7 @@ struct _GstMetaItem
|
||||||
|
|
||||||
#define GST_BUFFER_MEM_MAX 16
|
#define GST_BUFFER_MEM_MAX 16
|
||||||
|
|
||||||
|
#define GST_BUFFER_SLICE_SIZE(b) (((GstBufferImpl *)(b))->slice_size)
|
||||||
#define GST_BUFFER_MEM_LEN(b) (((GstBufferImpl *)(b))->len)
|
#define GST_BUFFER_MEM_LEN(b) (((GstBufferImpl *)(b))->len)
|
||||||
#define GST_BUFFER_MEM_ARRAY(b) (((GstBufferImpl *)(b))->mem)
|
#define GST_BUFFER_MEM_ARRAY(b) (((GstBufferImpl *)(b))->mem)
|
||||||
#define GST_BUFFER_MEM_PTR(b,i) (((GstBufferImpl *)(b))->mem[i])
|
#define GST_BUFFER_MEM_PTR(b,i) (((GstBufferImpl *)(b))->mem[i])
|
||||||
|
@ -148,6 +149,8 @@ typedef struct
|
||||||
{
|
{
|
||||||
GstBuffer buffer;
|
GstBuffer buffer;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
/* the memory blocks */
|
/* the memory blocks */
|
||||||
guint len;
|
guint len;
|
||||||
GstMemory *mem[GST_BUFFER_MEM_MAX];
|
GstMemory *mem[GST_BUFFER_MEM_MAX];
|
||||||
|
@ -505,7 +508,7 @@ _gst_buffer_free (GstBuffer * buffer)
|
||||||
|
|
||||||
/* get the size, when unreffing the memory, we could also unref the buffer
|
/* get the size, when unreffing the memory, we could also unref the buffer
|
||||||
* itself */
|
* itself */
|
||||||
msize = GST_MINI_OBJECT_SIZE (buffer);
|
msize = GST_BUFFER_SLICE_SIZE (buffer);
|
||||||
|
|
||||||
/* free our memory */
|
/* free our memory */
|
||||||
len = GST_BUFFER_MEM_LEN (buffer);
|
len = GST_BUFFER_MEM_LEN (buffer);
|
||||||
|
@ -522,7 +525,7 @@ _gst_buffer_free (GstBuffer * buffer)
|
||||||
static void
|
static void
|
||||||
gst_buffer_init (GstBufferImpl * buffer, gsize size)
|
gst_buffer_init (GstBufferImpl * buffer, gsize size)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (buffer), _gst_buffer_type, size);
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (buffer), _gst_buffer_type);
|
||||||
|
|
||||||
buffer->buffer.mini_object.copy =
|
buffer->buffer.mini_object.copy =
|
||||||
(GstMiniObjectCopyFunction) _gst_buffer_copy;
|
(GstMiniObjectCopyFunction) _gst_buffer_copy;
|
||||||
|
@ -531,6 +534,8 @@ gst_buffer_init (GstBufferImpl * buffer, gsize size)
|
||||||
buffer->buffer.mini_object.free =
|
buffer->buffer.mini_object.free =
|
||||||
(GstMiniObjectFreeFunction) _gst_buffer_free;
|
(GstMiniObjectFreeFunction) _gst_buffer_free;
|
||||||
|
|
||||||
|
GST_BUFFER_SLICE_SIZE (buffer) = size;
|
||||||
|
|
||||||
GST_BUFFER (buffer)->pool = NULL;
|
GST_BUFFER (buffer)->pool = NULL;
|
||||||
GST_BUFFER_PTS (buffer) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_PTS (buffer) = GST_CLOCK_TIME_NONE;
|
||||||
GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE;
|
||||||
|
|
|
@ -54,6 +54,8 @@ struct _GstBufferList
|
||||||
{
|
{
|
||||||
GstMiniObject mini_object;
|
GstMiniObject mini_object;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GArray *array;
|
GArray *array;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -97,18 +99,19 @@ _gst_buffer_list_free (GstBufferList * list)
|
||||||
gst_buffer_unref (g_array_index (list->array, GstBuffer *, i));
|
gst_buffer_unref (g_array_index (list->array, GstBuffer *, i));
|
||||||
g_array_free (list->array, TRUE);
|
g_array_free (list->array, TRUE);
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (list), list);
|
g_slice_free1 (list->slice_size, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_buffer_list_init (GstBufferList * list, gsize size, guint asize)
|
gst_buffer_list_init (GstBufferList * list, gsize size, guint asize)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (list), _gst_buffer_list_type,
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (list), _gst_buffer_list_type);
|
||||||
size);
|
|
||||||
|
|
||||||
list->mini_object.copy = (GstMiniObjectCopyFunction) _gst_buffer_list_copy;
|
list->mini_object.copy = (GstMiniObjectCopyFunction) _gst_buffer_list_copy;
|
||||||
list->mini_object.free = (GstMiniObjectFreeFunction) _gst_buffer_list_free;
|
list->mini_object.free = (GstMiniObjectFreeFunction) _gst_buffer_list_free;
|
||||||
|
|
||||||
|
list->slice_size = size;
|
||||||
|
|
||||||
list->array = g_array_sized_new (FALSE, FALSE, sizeof (GstBuffer *), asize);
|
list->array = g_array_sized_new (FALSE, FALSE, sizeof (GstBuffer *), asize);
|
||||||
|
|
||||||
GST_LOG ("init %p", list);
|
GST_LOG ("init %p", list);
|
||||||
|
|
|
@ -75,9 +75,12 @@ typedef struct _GstCapsImpl
|
||||||
{
|
{
|
||||||
GstCaps caps;
|
GstCaps caps;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GPtrArray *array;
|
GPtrArray *array;
|
||||||
} GstCapsImpl;
|
} GstCapsImpl;
|
||||||
|
|
||||||
|
#define GST_CAPS_SLICE_SIZE(c) (((GstCapsImpl *)(c))->slice_size)
|
||||||
#define GST_CAPS_ARRAY(c) (((GstCapsImpl *)(c))->array)
|
#define GST_CAPS_ARRAY(c) (((GstCapsImpl *)(c))->array)
|
||||||
|
|
||||||
#define GST_CAPS_LEN(c) (GST_CAPS_ARRAY(c)->len)
|
#define GST_CAPS_LEN(c) (GST_CAPS_ARRAY(c)->len)
|
||||||
|
@ -179,18 +182,19 @@ _gst_caps_free (GstCaps * caps)
|
||||||
#ifdef DEBUG_REFCOUNT
|
#ifdef DEBUG_REFCOUNT
|
||||||
GST_CAT_TRACE (GST_CAT_CAPS, "freeing caps %p", caps);
|
GST_CAT_TRACE (GST_CAT_CAPS, "freeing caps %p", caps);
|
||||||
#endif
|
#endif
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (caps), caps);
|
g_slice_free1 (GST_CAPS_SLICE_SIZE (caps), caps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_caps_init (GstCaps * caps, gsize size)
|
gst_caps_init (GstCaps * caps, gsize size)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (caps), _gst_caps_type, size);
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (caps), _gst_caps_type);
|
||||||
|
|
||||||
caps->mini_object.copy = (GstMiniObjectCopyFunction) _gst_caps_copy;
|
caps->mini_object.copy = (GstMiniObjectCopyFunction) _gst_caps_copy;
|
||||||
caps->mini_object.dispose = NULL;
|
caps->mini_object.dispose = NULL;
|
||||||
caps->mini_object.free = (GstMiniObjectFreeFunction) _gst_caps_free;
|
caps->mini_object.free = (GstMiniObjectFreeFunction) _gst_caps_free;
|
||||||
|
|
||||||
|
GST_CAPS_SLICE_SIZE (caps) = size;
|
||||||
/* the 32 has been determined by logging caps sizes in _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
|
* but g_ptr_array uses 16 anyway if it expands once, so this does not help
|
||||||
* in practice
|
* in practice
|
||||||
|
|
|
@ -92,9 +92,12 @@ typedef struct
|
||||||
{
|
{
|
||||||
GstEvent event;
|
GstEvent event;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
} GstEventImpl;
|
} GstEventImpl;
|
||||||
|
|
||||||
|
#define GST_EVENT_SLICE_SIZE(e) (((GstEventImpl *)(e))->slice_size)
|
||||||
#define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure)
|
#define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -229,7 +232,7 @@ _gst_event_free (GstEvent * event)
|
||||||
gst_structure_free (s);
|
gst_structure_free (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (event), event);
|
g_slice_free1 (GST_EVENT_SLICE_SIZE (event), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gst_event_init (GstEventImpl * event, gsize size,
|
static void gst_event_init (GstEventImpl * event, gsize size,
|
||||||
|
@ -262,11 +265,13 @@ _gst_event_copy (GstEvent * event)
|
||||||
static void
|
static void
|
||||||
gst_event_init (GstEventImpl * event, gsize size, GstEventType type)
|
gst_event_init (GstEventImpl * event, gsize size, GstEventType type)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (event), _gst_event_type, size);
|
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.copy = (GstMiniObjectCopyFunction) _gst_event_copy;
|
||||||
event->event.mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free;
|
event->event.mini_object.free = (GstMiniObjectFreeFunction) _gst_event_free;
|
||||||
|
|
||||||
|
GST_EVENT_SLICE_SIZE (event) = size;
|
||||||
|
|
||||||
GST_EVENT_TYPE (event) = type;
|
GST_EVENT_TYPE (event) = type;
|
||||||
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
|
GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE;
|
||||||
GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();
|
GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();
|
||||||
|
@ -318,7 +323,7 @@ gst_event_new_custom (GstEventType type, GstStructure * structure)
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
had_parent:
|
had_parent:
|
||||||
{
|
{
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (event), event);
|
g_slice_free1 (GST_EVENT_SLICE_SIZE (event), event);
|
||||||
g_warning ("structure is already owned by another object");
|
g_warning ("structure is already owned by another object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,8 @@ struct _GstAllocator
|
||||||
{
|
{
|
||||||
GstMiniObject mini_object;
|
GstMiniObject mini_object;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GstMemoryInfo info;
|
GstMemoryInfo info;
|
||||||
|
|
||||||
gpointer user_data;
|
gpointer user_data;
|
||||||
|
@ -105,6 +107,7 @@ struct _GstAllocator
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GstMemory mem;
|
GstMemory mem;
|
||||||
|
gsize slice_size;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
gpointer user_data;
|
gpointer user_data;
|
||||||
GDestroyNotify notify;
|
GDestroyNotify notify;
|
||||||
|
@ -137,8 +140,7 @@ _default_mem_init (GstMemoryDefault * mem, GstMemoryFlags flags,
|
||||||
gsize maxsize, gsize offset, gsize size, gsize align,
|
gsize maxsize, gsize offset, gsize size, gsize align,
|
||||||
gpointer user_data, GDestroyNotify notify)
|
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);
|
||||||
slice_size);
|
|
||||||
|
|
||||||
mem->mem.mini_object.copy = (GstMiniObjectCopyFunction) _gst_memory_copy;
|
mem->mem.mini_object.copy = (GstMiniObjectCopyFunction) _gst_memory_copy;
|
||||||
mem->mem.mini_object.dispose = NULL;
|
mem->mem.mini_object.dispose = NULL;
|
||||||
|
@ -152,6 +154,7 @@ _default_mem_init (GstMemoryDefault * mem, GstMemoryFlags flags,
|
||||||
mem->mem.align = align;
|
mem->mem.align = align;
|
||||||
mem->mem.offset = offset;
|
mem->mem.offset = offset;
|
||||||
mem->mem.size = size;
|
mem->mem.size = size;
|
||||||
|
mem->slice_size = slice_size;
|
||||||
mem->data = data;
|
mem->data = data;
|
||||||
mem->user_data = user_data;
|
mem->user_data = user_data;
|
||||||
mem->notify = notify;
|
mem->notify = notify;
|
||||||
|
@ -254,7 +257,7 @@ _default_mem_free (GstMemoryDefault * mem)
|
||||||
if (mem->notify)
|
if (mem->notify)
|
||||||
mem->notify (mem->user_data);
|
mem->notify (mem->user_data);
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (mem), mem);
|
g_slice_free1 (mem->slice_size, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstMemoryDefault *
|
static GstMemoryDefault *
|
||||||
|
@ -764,7 +767,7 @@ _gst_allocator_free (GstAllocator * allocator)
|
||||||
if (allocator->notify)
|
if (allocator->notify)
|
||||||
allocator->notify (allocator->user_data);
|
allocator->notify (allocator->user_data);
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (allocator), allocator);
|
g_slice_free1 (allocator->slice_size, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstAllocator *
|
static GstAllocator *
|
||||||
|
@ -804,12 +807,12 @@ gst_allocator_new (const GstMemoryInfo * info, gpointer user_data,
|
||||||
|
|
||||||
allocator = g_slice_new0 (GstAllocator);
|
allocator = g_slice_new0 (GstAllocator);
|
||||||
|
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (allocator),
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (allocator), GST_TYPE_ALLOCATOR);
|
||||||
GST_TYPE_ALLOCATOR, sizeof (GstAllocator));
|
|
||||||
|
|
||||||
allocator->mini_object.copy = (GstMiniObjectCopyFunction) _gst_allocator_copy;
|
allocator->mini_object.copy = (GstMiniObjectCopyFunction) _gst_allocator_copy;
|
||||||
allocator->mini_object.free = (GstMiniObjectFreeFunction) _gst_allocator_free;
|
allocator->mini_object.free = (GstMiniObjectFreeFunction) _gst_allocator_free;
|
||||||
|
|
||||||
|
allocator->slice_size = sizeof (GstAllocator);
|
||||||
allocator->info = *info;
|
allocator->info = *info;
|
||||||
allocator->user_data = user_data;
|
allocator->user_data = user_data;
|
||||||
allocator->notify = notify;
|
allocator->notify = notify;
|
||||||
|
|
|
@ -64,9 +64,12 @@ typedef struct
|
||||||
{
|
{
|
||||||
GstMessage message;
|
GstMessage message;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
} GstMessageImpl;
|
} GstMessageImpl;
|
||||||
|
|
||||||
|
#define GST_MESSAGE_SLICE_SIZE(m) (((GstMessageImpl *)(m))->slice_size)
|
||||||
#define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
|
#define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -198,7 +201,7 @@ _gst_message_free (GstMessage * message)
|
||||||
gst_structure_free (structure);
|
gst_structure_free (structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
|
g_slice_free1 (GST_MESSAGE_SLICE_SIZE (message), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -239,14 +242,15 @@ static void
|
||||||
gst_message_init (GstMessageImpl * message, gsize size, GstMessageType type,
|
gst_message_init (GstMessageImpl * message, gsize size, GstMessageType type,
|
||||||
GstObject * src)
|
GstObject * src)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (message), _gst_message_type,
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (message), _gst_message_type);
|
||||||
size);
|
|
||||||
|
|
||||||
message->message.mini_object.copy =
|
message->message.mini_object.copy =
|
||||||
(GstMiniObjectCopyFunction) _gst_message_copy;
|
(GstMiniObjectCopyFunction) _gst_message_copy;
|
||||||
message->message.mini_object.free =
|
message->message.mini_object.free =
|
||||||
(GstMiniObjectFreeFunction) _gst_message_free;
|
(GstMiniObjectFreeFunction) _gst_message_free;
|
||||||
|
|
||||||
|
GST_MESSAGE_SLICE_SIZE (message) = size;
|
||||||
|
|
||||||
GST_MESSAGE_TYPE (message) = type;
|
GST_MESSAGE_TYPE (message) = type;
|
||||||
if (src)
|
if (src)
|
||||||
gst_object_ref (src);
|
gst_object_ref (src);
|
||||||
|
@ -298,7 +302,7 @@ gst_message_new_custom (GstMessageType type, GstObject * src,
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
had_parent:
|
had_parent:
|
||||||
{
|
{
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
|
g_slice_free1 (GST_MESSAGE_SLICE_SIZE (message), message);
|
||||||
g_warning ("structure is already owned by another object");
|
g_warning ("structure is already owned by another object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,12 +80,11 @@ _priv_gst_mini_object_initialize (void)
|
||||||
* Returns: (transfer full): the new mini-object.
|
* Returns: (transfer full): the new mini-object.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_mini_object_init (GstMiniObject * mini_object, GType type, gsize size)
|
gst_mini_object_init (GstMiniObject * mini_object, GType type)
|
||||||
{
|
{
|
||||||
mini_object->type = type;
|
mini_object->type = type;
|
||||||
mini_object->refcount = 1;
|
mini_object->refcount = 1;
|
||||||
mini_object->flags = 0;
|
mini_object->flags = 0;
|
||||||
mini_object->size = size;
|
|
||||||
mini_object->n_weak_refs = 0;
|
mini_object->n_weak_refs = 0;
|
||||||
mini_object->weak_refs = NULL;
|
mini_object->weak_refs = NULL;
|
||||||
|
|
||||||
|
|
|
@ -149,14 +149,6 @@ typedef enum
|
||||||
*/
|
*/
|
||||||
#define GST_MINI_OBJECT_REFCOUNT_VALUE(obj) (g_atomic_int_get (&(GST_MINI_OBJECT_CAST(obj))->refcount))
|
#define GST_MINI_OBJECT_REFCOUNT_VALUE(obj) (g_atomic_int_get (&(GST_MINI_OBJECT_CAST(obj))->refcount))
|
||||||
|
|
||||||
/**
|
|
||||||
* GST_MINI_OBJECT_SIZE:
|
|
||||||
* @obj: a #GstMiniObject
|
|
||||||
*
|
|
||||||
* Get the allocated size of @obj.
|
|
||||||
*/
|
|
||||||
#define GST_MINI_OBJECT_SIZE(obj) ((GST_MINI_OBJECT_CAST(obj))->size)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstMiniObject:
|
* GstMiniObject:
|
||||||
* @type: the GType of the object
|
* @type: the GType of the object
|
||||||
|
@ -179,7 +171,6 @@ struct _GstMiniObject {
|
||||||
/*< public >*/ /* with COW */
|
/*< public >*/ /* with COW */
|
||||||
gint refcount;
|
gint refcount;
|
||||||
guint flags;
|
guint flags;
|
||||||
gsize size;
|
|
||||||
|
|
||||||
GstMiniObjectCopyFunction copy;
|
GstMiniObjectCopyFunction copy;
|
||||||
GstMiniObjectDisposeFunction dispose;
|
GstMiniObjectDisposeFunction dispose;
|
||||||
|
@ -195,8 +186,7 @@ struct _GstMiniObject {
|
||||||
} *weak_refs;
|
} *weak_refs;
|
||||||
};
|
};
|
||||||
|
|
||||||
void gst_mini_object_init (GstMiniObject *mini_object,
|
void gst_mini_object_init (GstMiniObject *mini_object, GType type);
|
||||||
GType type, gsize size);
|
|
||||||
|
|
||||||
GstMiniObject * gst_mini_object_copy (const GstMiniObject *mini_object) G_GNUC_MALLOC;
|
GstMiniObject * gst_mini_object_copy (const GstMiniObject *mini_object) G_GNUC_MALLOC;
|
||||||
gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object);
|
gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object);
|
||||||
|
|
|
@ -77,10 +77,12 @@ static GType _gst_query_type = 0;
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GstQuery query;
|
GstQuery query;
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
} GstQueryImpl;
|
} GstQueryImpl;
|
||||||
|
|
||||||
|
#define GST_QUERY_SLICE_SIZE(q) (((GstQueryImpl *)(q))->slice_size)
|
||||||
#define GST_QUERY_STRUCTURE(q) (((GstQueryImpl *)(q))->structure)
|
#define GST_QUERY_STRUCTURE(q) (((GstQueryImpl *)(q))->structure)
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,7 +204,7 @@ _gst_query_free (GstQuery * query)
|
||||||
gst_structure_free (s);
|
gst_structure_free (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (query), query);
|
g_slice_free1 (GST_QUERY_SLICE_SIZE (query), query);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstQuery *
|
static GstQuery *
|
||||||
|
@ -223,11 +225,12 @@ _gst_query_copy (GstQuery * query)
|
||||||
static void
|
static void
|
||||||
gst_query_init (GstQueryImpl * query, gsize size, GstQueryType type)
|
gst_query_init (GstQueryImpl * query, gsize size, GstQueryType type)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (query), _gst_query_type, size);
|
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.copy = (GstMiniObjectCopyFunction) _gst_query_copy;
|
||||||
query->query.mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
|
query->query.mini_object.free = (GstMiniObjectFreeFunction) _gst_query_free;
|
||||||
|
|
||||||
|
GST_QUERY_SLICE_SIZE (query) = size;
|
||||||
GST_QUERY_TYPE (query) = type;
|
GST_QUERY_TYPE (query) = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,7 +714,7 @@ gst_query_new_custom (GstQueryType type, GstStructure * structure)
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
had_parent:
|
had_parent:
|
||||||
{
|
{
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (query), query);
|
g_slice_free1 (GST_QUERY_SLICE_SIZE (query), query);
|
||||||
g_warning ("structure is already owned by another object");
|
g_warning ("structure is already owned by another object");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ struct _GstSample
|
||||||
{
|
{
|
||||||
GstMiniObject mini_object;
|
GstMiniObject mini_object;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GstBuffer *buffer;
|
GstBuffer *buffer;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
|
@ -74,7 +76,7 @@ _gst_sample_free (GstSample * sample)
|
||||||
if (sample->caps)
|
if (sample->caps)
|
||||||
gst_caps_unref (sample->caps);
|
gst_caps_unref (sample->caps);
|
||||||
|
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (sample), sample);
|
g_slice_free1 (sample->slice_size, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,12 +105,12 @@ gst_sample_new (GstBuffer * buffer, GstCaps * caps, const GstSegment * segment,
|
||||||
|
|
||||||
GST_LOG ("new %p", sample);
|
GST_LOG ("new %p", sample);
|
||||||
|
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (sample), _gst_sample_type,
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (sample), _gst_sample_type);
|
||||||
sizeof (GstSample));
|
|
||||||
|
|
||||||
sample->mini_object.copy = (GstMiniObjectCopyFunction) _gst_sample_copy;
|
sample->mini_object.copy = (GstMiniObjectCopyFunction) _gst_sample_copy;
|
||||||
sample->mini_object.free = (GstMiniObjectFreeFunction) _gst_sample_free;
|
sample->mini_object.free = (GstMiniObjectFreeFunction) _gst_sample_free;
|
||||||
|
|
||||||
|
sample->slice_size = sizeof (GstSample);
|
||||||
sample->buffer = buffer ? gst_buffer_ref (buffer) : NULL;
|
sample->buffer = buffer ? gst_buffer_ref (buffer) : NULL;
|
||||||
sample->caps = caps ? gst_caps_ref (caps) : NULL;
|
sample->caps = caps ? gst_caps_ref (caps) : NULL;
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,12 @@ typedef struct _GstTagListImpl
|
||||||
{
|
{
|
||||||
GstTagList taglist;
|
GstTagList taglist;
|
||||||
|
|
||||||
|
gsize slice_size;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
} GstTagListImpl;
|
} GstTagListImpl;
|
||||||
|
|
||||||
|
#define GST_TAG_LIST_SLICE_SIZE(taglist) ((GstTagListImpl*)(taglist))->slice_size
|
||||||
#define GST_TAG_LIST_STRUCTURE(taglist) ((GstTagListImpl*)(taglist))->structure
|
#define GST_TAG_LIST_STRUCTURE(taglist) ((GstTagListImpl*)(taglist))->structure
|
||||||
|
|
||||||
|
|
||||||
|
@ -666,11 +669,13 @@ static void
|
||||||
gst_tag_list_init (GstTagList * taglist, gsize size)
|
gst_tag_list_init (GstTagList * taglist, gsize size)
|
||||||
{
|
{
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (taglist),
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (taglist),
|
||||||
gst_tag_list_get_type (), size);
|
gst_tag_list_get_type ());
|
||||||
|
|
||||||
taglist->mini_object.copy = (GstMiniObjectCopyFunction) __gst_tag_list_copy;
|
taglist->mini_object.copy = (GstMiniObjectCopyFunction) __gst_tag_list_copy;
|
||||||
taglist->mini_object.dispose = NULL;
|
taglist->mini_object.dispose = NULL;
|
||||||
taglist->mini_object.free = (GstMiniObjectFreeFunction) __gst_tag_list_free;
|
taglist->mini_object.free = (GstMiniObjectFreeFunction) __gst_tag_list_free;
|
||||||
|
|
||||||
|
GST_TAG_LIST_SLICE_SIZE (taglist) = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* takes ownership of the structure */
|
/* takes ownership of the structure */
|
||||||
|
@ -706,7 +711,7 @@ __gst_tag_list_free (GstTagList * list)
|
||||||
gst_structure_free (GST_TAG_LIST_STRUCTURE (list));
|
gst_structure_free (GST_TAG_LIST_STRUCTURE (list));
|
||||||
|
|
||||||
/* why not just pass sizeof (GstTagListImpl) here? */
|
/* why not just pass sizeof (GstTagListImpl) here? */
|
||||||
g_slice_free1 (GST_MINI_OBJECT_SIZE (list), list);
|
g_slice_free1 (GST_TAG_LIST_SLICE_SIZE (list), list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstTagList *
|
static GstTagList *
|
||||||
|
|
Loading…
Reference in a new issue