mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 17:05:52 +00:00
GstAllocator: Add GST_ALLOCATOR_FLAG_NO_COPY flag
Detail a bit the intention behind GST_ALLOCATOR_FLAG_CUSTOM_ALLOC, even if implementation does not currently fully follow that usage. Introduce a new flag specifically for copying memories using the default system allocator. Sponsored-by: Netflix Inc. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5328>
This commit is contained in:
parent
e3e8147a74
commit
24c34cadec
2 changed files with 20 additions and 1 deletions
|
@ -104,7 +104,8 @@ _fallback_mem_copy (GstMemory * mem, gssize offset, gssize size)
|
||||||
|
|
||||||
/* use the same allocator as the memory we copy */
|
/* use the same allocator as the memory we copy */
|
||||||
allocator = mem->allocator;
|
allocator = mem->allocator;
|
||||||
if (GST_OBJECT_FLAG_IS_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC))
|
if (GST_OBJECT_FLAG_IS_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC) ||
|
||||||
|
GST_OBJECT_FLAG_IS_SET (allocator, GST_ALLOCATOR_FLAG_NO_COPY))
|
||||||
allocator = NULL;
|
allocator = NULL;
|
||||||
copy = gst_allocator_alloc (allocator, size, ¶ms);
|
copy = gst_allocator_alloc (allocator, size, ¶ms);
|
||||||
|
|
||||||
|
|
|
@ -84,12 +84,30 @@ struct _GstAllocationParams {
|
||||||
/**
|
/**
|
||||||
* GstAllocatorFlags:
|
* GstAllocatorFlags:
|
||||||
* @GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: The allocator has a custom alloc function.
|
* @GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: The allocator has a custom alloc function.
|
||||||
|
* Only elements designed to work with this allocator should be using it,
|
||||||
|
* other elements should ignore it from allocation propositions.
|
||||||
|
* This implies %GST_ALLOCATOR_FLAG_NO_COPY.
|
||||||
|
* @GST_ALLOCATOR_FLAG_NO_COPY: When copying a #GstMemory allocated with this
|
||||||
|
* allocator, the copy will instead be allocated using the default allocator.
|
||||||
|
* Use this when allocating a new memory is an heavy opperation that should
|
||||||
|
* only be done with a #GstBufferPool for example. (Since: 1.24)
|
||||||
* @GST_ALLOCATOR_FLAG_LAST: first flag that can be used for custom purposes
|
* @GST_ALLOCATOR_FLAG_LAST: first flag that can be used for custom purposes
|
||||||
*
|
*
|
||||||
* Flags for allocators.
|
* Flags for allocators.
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* GST_ALLOCATOR_FLAG_NO_COPY:
|
||||||
|
*
|
||||||
|
* When copying a #GstMemory allocated with this allocator, the copy will
|
||||||
|
* instead be allocated using the default allocator. Use this when allocating a
|
||||||
|
* new memory is an heavy opperation that should only be done with a
|
||||||
|
* #GstBufferPool for example.
|
||||||
|
*
|
||||||
|
* Since: 1.24
|
||||||
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
GST_ALLOCATOR_FLAG_CUSTOM_ALLOC = (GST_OBJECT_FLAG_LAST << 0),
|
GST_ALLOCATOR_FLAG_CUSTOM_ALLOC = (GST_OBJECT_FLAG_LAST << 0),
|
||||||
|
GST_ALLOCATOR_FLAG_NO_COPY = (GST_OBJECT_FLAG_LAST << 1),
|
||||||
|
|
||||||
GST_ALLOCATOR_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
|
GST_ALLOCATOR_FLAG_LAST = (GST_OBJECT_FLAG_LAST << 16)
|
||||||
} GstAllocatorFlags;
|
} GstAllocatorFlags;
|
||||||
|
|
Loading…
Reference in a new issue