* Typically, #GstParentBufferMeta is used when the child buffer is directly
* using the #GstMemory of the parent buffer, and wants to prevent the parent
* buffer from being returned to a buffer pool until the #GstMemory is available
- * for re-use. (Since 1.6)
+ * for re-use. (Since: 1.6)
*
*/
#include "gst_private.h"
#define GST_BUFFER_MEM_PTR(b,i) (((GstBufferImpl *)(b))->mem[i])
#define GST_BUFFER_BUFMEM(b) (((GstBufferImpl *)(b))->bufmem)
#define GST_BUFFER_META(b) (((GstBufferImpl *)(b))->item)
+#define GST_BUFFER_TAIL_META(b) (((GstBufferImpl *)(b))->tail_item)
typedef struct
{
/* FIXME, make metadata allocation more efficient by using part of the
* GstBufferImpl */
GstMetaItem *item;
+ GstMetaItem *tail_item;
} GstBufferImpl;
static gint64 meta_seq; /* 0 *//* ATOMIC */
static inline gint64
gst_atomic_int64_inc (volatile gint64 * atomic)
{
- InterlockedExchangeAdd (atomic, 1);
+ return InterlockedExchangeAdd64 (atomic, 1);
}
#else
#warning No 64-bit atomic int defined for this platform/toolchain!
/* ERROR */
not_writable:
{
- GST_WARNING_OBJECT (buffer, "write map requested on non-writable buffer");
+ GST_WARNING ("write map requested on non-writable buffer");
g_critical ("write map requested on non-writable buffer");
memset (info, 0, sizeof (GstMapInfo));
return FALSE;
no_memory:
{
/* empty buffer, we need to return NULL */
- GST_DEBUG_OBJECT (buffer, "can't get buffer memory");
+ GST_DEBUG ("can't get buffer memory");
memset (info, 0, sizeof (GstMapInfo));
return TRUE;
}
cannot_map:
{
- GST_DEBUG_OBJECT (buffer, "cannot map memory");
+ GST_DEBUG ("cannot map memory");
memset (info, 0, sizeof (GstMapInfo));
return FALSE;
}
goto init_failed;
item->seq_num = gst_atomic_int64_inc (&meta_seq);
+ item->next = NULL;
- /* and add to the list of metadata */
- item->next = GST_BUFFER_META (buffer);
- GST_BUFFER_META (buffer) = item;
+ if (!GST_BUFFER_META (buffer)) {
+ GST_BUFFER_META (buffer) = item;
+ GST_BUFFER_TAIL_META (buffer) = item;
+ } else {
+ GST_BUFFER_TAIL_META (buffer)->next = item;
+ GST_BUFFER_TAIL_META (buffer) = item;
+ }
return result;
const GstMetaInfo *info = meta->info;
/* remove from list */
+ if (GST_BUFFER_TAIL_META (buffer) == walk) {
+ if (prev != walk)
+ GST_BUFFER_TAIL_META (buffer) = prev;
+ else
+ GST_BUFFER_TAIL_META (buffer) = NULL;
+ }
+
if (GST_BUFFER_META (buffer) == walk)
GST_BUFFER_META (buffer) = walk->next;
else
prev->next = walk->next;
+
/* call free_func if any */
if (info->free_func)
info->free_func (m, buffer);
g_return_val_if_fail (!GST_META_FLAG_IS_SET (m, GST_META_FLAG_LOCKED),
FALSE);
+ if (GST_BUFFER_TAIL_META (buffer) == walk) {
+ if (prev != walk)
+ GST_BUFFER_TAIL_META (buffer) = prev;
+ else
+ GST_BUFFER_TAIL_META (buffer) = NULL;
+ }
+
/* remove from list */
if (GST_BUFFER_META (buffer) == walk)
prev = GST_BUFFER_META (buffer) = next;