GstMetaItem *next;
GstMeta meta;
};
-#define ITEM_SIZE(info) ((info)->size + sizeof (GstMetaItem))
+
+/* info->size will be sizeof(FooMeta) which contains a GstMeta at the beginning
+ * too, and then there is again a GstMeta in GstMetaItem, so subtract one. */
+#define ITEM_SIZE(info) ((info)->size + sizeof (GstMetaItem) - sizeof (GstMeta))
#define GST_BUFFER_MEM_MAX 16
GstMemory *old = GST_BUFFER_MEM_PTR (buffer, i);
gst_memory_unlock (old, GST_LOCK_FLAG_EXCLUSIVE);
+ gst_mini_object_remove_parent (GST_MINI_OBJECT_CAST (old),
+ GST_MINI_OBJECT_CAST (buffer));
gst_memory_unref (old);
}
if (mem != NULL) {
/* replace with single memory */
+ gst_mini_object_add_parent (GST_MINI_OBJECT_CAST (mem),
+ GST_MINI_OBJECT_CAST (buffer));
gst_memory_lock (mem, GST_LOCK_FLAG_EXCLUSIVE);
GST_BUFFER_MEM_PTR (buffer, idx) = mem;
idx++;
/* and insert the new buffer */
GST_BUFFER_MEM_PTR (buffer, idx) = mem;
GST_BUFFER_MEM_LEN (buffer) = len + 1;
+ gst_mini_object_add_parent (GST_MINI_OBJECT_CAST (mem),
+ GST_MINI_OBJECT_CAST (buffer));
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
len = GST_BUFFER_MEM_LEN (buffer);
for (i = 0; i < len; i++) {
gst_memory_unlock (GST_BUFFER_MEM_PTR (buffer, i), GST_LOCK_FLAG_EXCLUSIVE);
+ gst_mini_object_remove_parent (GST_MINI_OBJECT_CAST (GST_BUFFER_MEM_PTR
+ (buffer, i)), GST_MINI_OBJECT_CAST (buffer));
gst_memory_unref (GST_BUFFER_MEM_PTR (buffer, i));
}
if (mapped != mem) {
/* memory changed, lock new memory */
+ gst_mini_object_add_parent (GST_MINI_OBJECT_CAST (mapped),
+ GST_MINI_OBJECT_CAST (buffer));
gst_memory_lock (mapped, GST_LOCK_FLAG_EXCLUSIVE);
GST_BUFFER_MEM_PTR (buffer, idx) = mapped;
/* unlock old memory */
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
+ gst_mini_object_remove_parent (GST_MINI_OBJECT_CAST (mem),
+ GST_MINI_OBJECT_CAST (buffer));
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
}
gst_memory_unref (mem);
if (newmem == NULL)
return FALSE;
+ gst_mini_object_add_parent (GST_MINI_OBJECT_CAST (newmem),
+ GST_MINI_OBJECT_CAST (buffer));
gst_memory_lock (newmem, GST_LOCK_FLAG_EXCLUSIVE);
GST_BUFFER_MEM_PTR (buffer, i) = newmem;
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
+ gst_mini_object_remove_parent (GST_MINI_OBJECT_CAST (mem),
+ GST_MINI_OBJECT_CAST (buffer));
gst_memory_unref (mem);
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
* gst_buffer_extract:
* @buffer: a #GstBuffer.
* @offset: the offset to extract
- * @dest: the destination address
+ * @dest: (out caller-allocates) (array length=size) (element-type guint8):
+ * the destination address
* @size: the size to extract
*
* Copy @size bytes starting from @offset in @buffer to @dest.
GstMemory *mem;
mem = GST_BUFFER_MEM_PTR (buf2, i);
+ gst_mini_object_remove_parent (GST_MINI_OBJECT_CAST (mem),
+ GST_MINI_OBJECT_CAST (buf2));
GST_BUFFER_MEM_PTR (buf2, i) = NULL;
_memory_add (buf1, -1, mem);
}
/**
* gst_buffer_iterate_meta: (skip)
* @buffer: a #GstBuffer
- * @state: an opaque state pointer
+ * @state: (out caller-allocates): an opaque state pointer
*
* Retrieve the next #GstMeta after @current. If @state points
* to %NULL, the first metadata is returned.
/**
* gst_buffer_iterate_meta_filtered: (skip)
* @buffer: a #GstBuffer
- * @state: an opaque state pointer
+ * @state: (out caller-allocates): an opaque state pointer
* @meta_api_type: only return #GstMeta of this type
*
* Retrieve the next #GstMeta of type @meta_api_type after the current one