mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
va: pool: use allocator pool at alloc()
Check if the allocator pool has memories available before creating a new one, but only iif pool is not starting. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2013>
This commit is contained in:
parent
800a49e8de
commit
8deec238cb
3 changed files with 27 additions and 6 deletions
|
@ -1389,6 +1389,17 @@ gst_va_allocator_new (GstVaDisplay * display, GArray * surface_formats)
|
|||
return GST_ALLOCATOR (self);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_va_allocator_setup_buffer (GstAllocator * allocator, GstBuffer * buffer)
|
||||
{
|
||||
GstMemory *mem = gst_va_allocator_alloc (allocator);
|
||||
if (!mem)
|
||||
return FALSE;
|
||||
|
||||
gst_buffer_append_memory (buffer, mem);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VASurfaceID
|
||||
gst_va_allocator_prepare_buffer_unlocked (GstVaAllocator * self,
|
||||
GstBuffer * buffer)
|
||||
|
|
|
@ -64,6 +64,8 @@ G_DECLARE_FINAL_TYPE (GstVaAllocator, gst_va_allocator, GST, VA_ALLOCATOR, GstAl
|
|||
GstAllocator * gst_va_allocator_new (GstVaDisplay * display,
|
||||
GArray * surface_formats);
|
||||
GstMemory * gst_va_allocator_alloc (GstAllocator * allocator);
|
||||
gboolean gst_va_allocator_setup_buffer (GstAllocator * allocator,
|
||||
GstBuffer * buffer);
|
||||
gboolean gst_va_allocator_prepare_buffer (GstAllocator * allocator,
|
||||
GstBuffer * buffer);
|
||||
gboolean gst_va_allocator_wait_for_memory (GstAllocator * allocator,
|
||||
|
|
|
@ -228,13 +228,21 @@ gst_va_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
buf = gst_buffer_new ();
|
||||
|
||||
if (GST_IS_VA_DMABUF_ALLOCATOR (vpool->allocator)) {
|
||||
if (!gst_va_dmabuf_allocator_setup_buffer (vpool->allocator, buf))
|
||||
goto no_memory;
|
||||
if (vpool->starting) {
|
||||
if (!gst_va_dmabuf_allocator_setup_buffer (vpool->allocator, buf))
|
||||
goto no_memory;
|
||||
} else if (!gst_va_dmabuf_allocator_prepare_buffer (vpool->allocator, buf)) {
|
||||
if (!gst_va_dmabuf_allocator_setup_buffer (vpool->allocator, buf))
|
||||
goto no_memory;
|
||||
}
|
||||
} else if (GST_IS_VA_ALLOCATOR (vpool->allocator)) {
|
||||
GstMemory *mem = gst_va_allocator_alloc (vpool->allocator);
|
||||
if (!mem)
|
||||
goto no_memory;
|
||||
gst_buffer_append_memory (buf, mem);
|
||||
if (vpool->starting) {
|
||||
if (!gst_va_allocator_setup_buffer (vpool->allocator, buf))
|
||||
goto no_memory;
|
||||
} else if (!gst_va_allocator_prepare_buffer (vpool->allocator, buf)) {
|
||||
if (!gst_va_allocator_setup_buffer (vpool->allocator, buf))
|
||||
goto no_memory;
|
||||
}
|
||||
} else
|
||||
goto no_memory;
|
||||
|
||||
|
|
Loading…
Reference in a new issue