mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
buffer: add a new flag to track memory changes
Add a flag to check if the memory changed in a buffer.
This commit is contained in:
parent
86f506e9d8
commit
5bca002f4b
2 changed files with 14 additions and 0 deletions
|
@ -286,6 +286,7 @@ _replace_memory (GstBuffer * buffer, guint len, guint idx, guint length,
|
|||
&GST_BUFFER_MEM_PTR (buffer, end), (len - end) * sizeof (gpointer));
|
||||
}
|
||||
GST_BUFFER_MEM_LEN (buffer) = len - length;
|
||||
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -320,6 +321,8 @@ _memory_add (GstBuffer * buffer, gint idx, GstMemory * mem, gboolean lock)
|
|||
gst_memory_lock (mem, GST_LOCK_FLAG_EXCLUSIVE);
|
||||
GST_BUFFER_MEM_PTR (buffer, idx) = mem;
|
||||
GST_BUFFER_MEM_LEN (buffer) = len + 1;
|
||||
|
||||
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
}
|
||||
|
||||
GST_DEFINE_MINI_OBJECT_TYPE (GstBuffer, gst_buffer);
|
||||
|
@ -519,6 +522,8 @@ _gst_buffer_copy (GstBuffer * buffer)
|
|||
if (!gst_buffer_copy_into (copy, buffer, GST_BUFFER_COPY_ALL, 0, -1))
|
||||
gst_buffer_replace (©, NULL);
|
||||
|
||||
GST_BUFFER_FLAG_SET (copy, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
@ -723,6 +728,7 @@ gst_buffer_new_allocate (GstAllocator * allocator, gsize size,
|
|||
if (size > 0)
|
||||
_memory_add (newbuf, -1, gst_memory_ref (mem), TRUE);
|
||||
#endif
|
||||
GST_BUFFER_FLAG_SET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
|
||||
return newbuf;
|
||||
|
||||
|
@ -769,6 +775,7 @@ gst_buffer_new_wrapped_full (GstMemoryFlags flags, gpointer data,
|
|||
gst_memory_new_wrapped (flags, data, maxsize, offset, size, user_data,
|
||||
notify);
|
||||
_memory_add (newbuf, -1, mem, TRUE);
|
||||
GST_BUFFER_FLAG_SET (newbuf, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
|
||||
return newbuf;
|
||||
}
|
||||
|
@ -883,6 +890,7 @@ _get_mapped (GstBuffer * buffer, guint idx, GstMapInfo * info,
|
|||
GST_BUFFER_MEM_PTR (buffer, idx) = mapped;
|
||||
/* unlock old memory */
|
||||
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
|
||||
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
}
|
||||
gst_memory_unref (mem);
|
||||
|
||||
|
@ -1393,7 +1401,9 @@ gst_buffer_resize_range (GstBuffer * buffer, guint idx, gint length,
|
|||
GST_BUFFER_MEM_PTR (buffer, i) = newmem;
|
||||
gst_memory_unlock (mem, GST_LOCK_FLAG_EXCLUSIVE);
|
||||
gst_memory_unref (mem);
|
||||
|
||||
}
|
||||
GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
}
|
||||
|
||||
offset = noffs;
|
||||
|
@ -1853,6 +1863,7 @@ gst_buffer_append_region (GstBuffer * buf1, GstBuffer * buf2, gssize offset,
|
|||
}
|
||||
|
||||
GST_BUFFER_MEM_LEN (buf2) = 0;
|
||||
GST_BUFFER_FLAG_UNSET (buf2, GST_BUFFER_FLAG_TAG_MEMORY);
|
||||
gst_buffer_unref (buf2);
|
||||
|
||||
return buf1;
|
||||
|
|
|
@ -192,6 +192,8 @@ typedef struct _GstBufferPool GstBufferPool;
|
|||
* @GST_BUFFER_FLAG_DROPPABLE: the buffer can be dropped without breaking the
|
||||
* stream, for example to reduce bandwidth.
|
||||
* @GST_BUFFER_FLAG_DELTA_UNIT: this unit cannot be decoded independently.
|
||||
* @GST_BUFFER_FLAG_TAG_MEMORY: this flag is cleared when the memory of the buffer
|
||||
* is added/removed
|
||||
* @GST_BUFFER_FLAG_LAST: additional media specific flags can be added starting from
|
||||
* this flag.
|
||||
*
|
||||
|
@ -208,6 +210,7 @@ typedef enum {
|
|||
GST_BUFFER_FLAG_GAP = (GST_MINI_OBJECT_FLAG_LAST << 7),
|
||||
GST_BUFFER_FLAG_DROPPABLE = (GST_MINI_OBJECT_FLAG_LAST << 8),
|
||||
GST_BUFFER_FLAG_DELTA_UNIT = (GST_MINI_OBJECT_FLAG_LAST << 9),
|
||||
GST_BUFFER_FLAG_TAG_MEMORY = (GST_MINI_OBJECT_FLAG_LAST << 10),
|
||||
|
||||
GST_BUFFER_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 16)
|
||||
} GstBufferFlags;
|
||||
|
|
Loading…
Reference in a new issue