diff options
author | Hyunjun Ko <zzoon@igalia.com> | 2018-03-30 15:41:15 +0900 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2018-04-26 16:40:54 -0400 |
commit | 56ab7e0e1d0ebcbfef48c6a1ce89463a415c8e9d (patch) | |
tree | ba62af3b70a53e26cf0e6e230638027bd801e056 | |
parent | e7700f20fd3cc52014d878637ca4a1780742108a (diff) |
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
-rw-r--r-- | docs/libs/gst-plugins-base-libs-sections.txt | 1 | ||||
-rw-r--r-- | gst-libs/gst/allocators/gstdmabuf.c | 26 | ||||
-rw-r--r-- | gst-libs/gst/allocators/gstdmabuf.h | 3 |
3 files changed, 30 insertions, 0 deletions
diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 828429a0f..64c5d9112 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -7,6 +7,7 @@ GST_CAPS_FEATURE_MEMORY_DMABUF gst_dmabuf_allocator_new gst_dmabuf_allocator_alloc +gst_dmabuf_allocator_alloc_with_flags gst_dmabuf_memory_get_fd gst_is_dmabuf_memory <SUBSECTION Standard> diff --git a/gst-libs/gst/allocators/gstdmabuf.c b/gst-libs/gst/allocators/gstdmabuf.c index c7897ef84..fbe5ec399 100644 --- a/gst-libs/gst/allocators/gstdmabuf.c +++ b/gst-libs/gst/allocators/gstdmabuf.c @@ -158,6 +158,32 @@ gst_dmabuf_allocator_alloc (GstAllocator * allocator, gint fd, gsize size) } /** + * 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: * @mem: the memory to get the file descriptor * diff --git a/gst-libs/gst/allocators/gstdmabuf.h b/gst-libs/gst/allocators/gstdmabuf.h index dd5e94fe5..3707f88c3 100644 --- a/gst-libs/gst/allocators/gstdmabuf.h +++ b/gst-libs/gst/allocators/gstdmabuf.h @@ -105,6 +105,9 @@ GST_ALLOCATORS_API 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 gint gst_dmabuf_memory_get_fd (GstMemory * mem); GST_ALLOCATORS_API |