mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
allocator: improve fallback copy function
Only use the allocator of the copied memory when we can use the default _alloc function on it. Otherwise we will have to use the default allocator for the copy.
This commit is contained in:
parent
f34d5bfa0f
commit
7e222212a8
1 changed files with 6 additions and 1 deletions
|
@ -95,6 +95,7 @@ _fallback_mem_copy (GstMemory * mem, gssize offset, gssize size)
|
|||
GstMemory *copy;
|
||||
GstMapInfo sinfo, dinfo;
|
||||
GstAllocationParams params = { 0, mem->align, 0, 0, };
|
||||
GstAllocator *allocator;
|
||||
|
||||
if (!gst_memory_map (mem, &sinfo, GST_MAP_READ))
|
||||
return NULL;
|
||||
|
@ -103,7 +104,11 @@ _fallback_mem_copy (GstMemory * mem, gssize offset, gssize size)
|
|||
size = sinfo.size > offset ? sinfo.size - offset : 0;
|
||||
|
||||
/* use the same allocator as the memory we copy */
|
||||
copy = gst_allocator_alloc (mem->allocator, size, ¶ms);
|
||||
allocator = mem->allocator;
|
||||
if (GST_OBJECT_FLAG_IS_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC))
|
||||
allocator = NULL;
|
||||
copy = gst_allocator_alloc (allocator, size, ¶ms);
|
||||
|
||||
if (!gst_memory_map (copy, &dinfo, GST_MAP_WRITE)) {
|
||||
GST_CAT_WARNING (GST_CAT_MEMORY, "could not write map memory %p", copy);
|
||||
gst_allocator_free (mem->allocator, copy);
|
||||
|
|
Loading…
Reference in a new issue