dmabufallocator: adds gst_dmabuf_allocator_alloc_with_flags
If we can guarantee the lifetime of the fd is longer than the memory, we can use DONT_CLOSE flag not to close when release. But it's not provided in gstdmabuf yet while gstfdmemory does. For example, in case of using VA-API or MSDK, we would need this api. Otherwise we should call dup to duplicate the fd. https://bugzilla.gnome.org/show_bug.cgi?id=794829
This commit is contained in:
parent
e7700f20fd
commit
56ab7e0e1d
@ -7,6 +7,7 @@
|
|||||||
GST_CAPS_FEATURE_MEMORY_DMABUF
|
GST_CAPS_FEATURE_MEMORY_DMABUF
|
||||||
gst_dmabuf_allocator_new
|
gst_dmabuf_allocator_new
|
||||||
gst_dmabuf_allocator_alloc
|
gst_dmabuf_allocator_alloc
|
||||||
|
gst_dmabuf_allocator_alloc_with_flags
|
||||||
gst_dmabuf_memory_get_fd
|
gst_dmabuf_memory_get_fd
|
||||||
gst_is_dmabuf_memory
|
gst_is_dmabuf_memory
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
|
@ -157,6 +157,32 @@ gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size)
|
|||||||
return gst_fd_allocator_alloc (allocator, fd, size, GST_FD_MEMORY_FLAG_NONE);
|
return gst_fd_allocator_alloc (allocator, fd, size, GST_FD_MEMORY_FLAG_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_dmabuf_allocator_alloc_with_flags:
|
||||||
|
* @allocator: allocator to be used for this memory
|
||||||
|
* @fd: dmabuf file descriptor
|
||||||
|
* @size: memory size
|
||||||
|
* @flags: extra #GstFdMemoryFlags
|
||||||
|
*
|
||||||
|
* Return a %GstMemory that wraps a dmabuf file descriptor.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a GstMemory based on @allocator.
|
||||||
|
*
|
||||||
|
* When the buffer will be released the allocator will close the @fd unless
|
||||||
|
* the %GST_FD_MEMORY_FLAG_DONT_CLOSE flag is specified.
|
||||||
|
* The memory is only mmapped on gst_buffer_mmap() request.
|
||||||
|
*
|
||||||
|
* Since: 1.16
|
||||||
|
*/
|
||||||
|
GstMemory *
|
||||||
|
gst_dmabuf_allocator_alloc_with_flags (GstAllocator * allocator, gint fd,
|
||||||
|
gsize size, GstFdMemoryFlags flags)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_DMABUF_ALLOCATOR (allocator), NULL);
|
||||||
|
|
||||||
|
return gst_fd_allocator_alloc (allocator, fd, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_dmabuf_memory_get_fd:
|
* gst_dmabuf_memory_get_fd:
|
||||||
* @mem: the memory to get the file descriptor
|
* @mem: the memory to get the file descriptor
|
||||||
|
@ -104,6 +104,9 @@ GstAllocator * gst_dmabuf_allocator_new (void);
|
|||||||
GST_ALLOCATORS_API
|
GST_ALLOCATORS_API
|
||||||
GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size);
|
GstMemory * gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size);
|
||||||
|
|
||||||
|
GST_ALLOCATORS_API
|
||||||
|
GstMemory * gst_dmabuf_allocator_alloc_with_flags (GstAllocator * allocator, gint fd, gsize size, GstFdMemoryFlags flags);
|
||||||
|
|
||||||
GST_ALLOCATORS_API
|
GST_ALLOCATORS_API
|
||||||
gint gst_dmabuf_memory_get_fd (GstMemory * mem);
|
gint gst_dmabuf_memory_get_fd (GstMemory * mem);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user