vaapivideomemory: refactor code for readability

Added the inlined function allocator_configure_pools() moving out code
from gst_vaapi_video_allocator_new() to make clear that it is a
post-initalization of the object.
This commit is contained in:
Víctor Manuel Jáquez Leal 2016-11-14 17:45:55 +01:00
parent b9b8c26c40
commit ad8da84062

View file

@ -825,20 +825,11 @@ error:
} }
} }
GstAllocator * static inline gboolean
gst_vaapi_video_allocator_new (GstVaapiDisplay * display, allocator_params_init (GstVaapiVideoAllocator * allocator,
const GstVideoInfo * vip, guint surface_alloc_flags, GstVaapiDisplay * display, const GstVideoInfo * vip,
GstVaapiImageUsageFlags req_usage_flag) guint surface_alloc_flags, GstVaapiImageUsageFlags req_usage_flag)
{ {
GstVaapiVideoAllocator *allocator;
g_return_val_if_fail (display != NULL, NULL);
g_return_val_if_fail (vip != NULL, NULL);
allocator = g_object_new (GST_VAAPI_TYPE_VIDEO_ALLOCATOR, NULL);
if (!allocator)
return NULL;
allocator->allocation_info = *vip; allocator->allocation_info = *vip;
allocator_configure_surface_info (display, allocator, req_usage_flag); allocator_configure_surface_info (display, allocator, req_usage_flag);
@ -855,21 +846,43 @@ gst_vaapi_video_allocator_new (GstVaapiDisplay * display,
gst_allocator_set_vaapi_video_info (GST_ALLOCATOR_CAST (allocator), gst_allocator_set_vaapi_video_info (GST_ALLOCATOR_CAST (allocator),
&allocator->image_info, surface_alloc_flags); &allocator->image_info, surface_alloc_flags);
return GST_ALLOCATOR_CAST (allocator);
return TRUE;
/* ERRORS */ /* ERRORS */
error_create_surface_pool: error_create_surface_pool:
{ {
GST_ERROR ("failed to allocate VA surface pool"); GST_ERROR ("failed to allocate VA surface pool");
gst_object_unref (allocator); return FALSE;
return NULL;
} }
error_create_image_pool: error_create_image_pool:
{ {
GST_ERROR ("failed to allocate VA image pool"); GST_ERROR ("failed to allocate VA image pool");
gst_object_unref (allocator); return FALSE;
}
}
GstAllocator *
gst_vaapi_video_allocator_new (GstVaapiDisplay * display,
const GstVideoInfo * vip, guint surface_alloc_flags,
GstVaapiImageUsageFlags req_usage_flag)
{
GstVaapiVideoAllocator *allocator;
g_return_val_if_fail (display != NULL, NULL);
g_return_val_if_fail (vip != NULL, NULL);
allocator = g_object_new (GST_VAAPI_TYPE_VIDEO_ALLOCATOR, NULL);
if (!allocator)
return NULL;
if (!allocator_params_init (allocator, display, vip, surface_alloc_flags,
req_usage_flag)) {
g_object_unref (allocator);
return NULL; return NULL;
} }
return GST_ALLOCATOR_CAST (allocator);
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */