summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/va/surface.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2017-01-25 14:46:53 +0100
committerChristian König <[email protected]>2017-03-13 08:51:32 +0100
commit1ce68af07b38f6f9c9f8c7b42d30b0c3026b1ceb (patch)
treec3aff993decfde7c9eaea2083a76dd35561102dc /src/gallium/state_trackers/va/surface.c
parent88f34510832d4468fe887b6383d2006d9b85fb9b (diff)
st/va: cleanup error handling in vlVaCreateSurfaces2
No need to have that twice. Signed-off-by: Christian König <[email protected]> Reviewed-by: Mark Thompson <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/va/surface.c')
-rw-r--r--src/gallium/state_trackers/va/surface.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index 1d8d981d1c2..3561117d42f 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -488,8 +488,7 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config_id,
static VAStatus
suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
VASurfaceAttribExternalBuffers *memory_attibute,
- int index, VASurfaceID *surfaces,
- struct pipe_video_buffer *templat)
+ unsigned index, struct pipe_video_buffer *templat)
{
vlVaDriver *drv;
struct pipe_screen *pscreen;
@@ -498,9 +497,6 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
struct winsys_handle whandle;
struct pipe_resource *resources[VL_NUM_COMPONENTS];
- if (!ctx)
- return VA_STATUS_ERROR_INVALID_PARAMETER;
-
pscreen = VL_VA_PSCREEN(ctx);
drv = VL_VA_DRIVER(ctx);
@@ -554,14 +550,6 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface,
if (!surface->buffer)
return VA_STATUS_ERROR_ALLOCATION_FAILED;
- util_dynarray_init(&surface->subpics);
- surfaces[index] = handle_table_add(drv->htab, surface);
-
- if (!surfaces[index]) {
- surface->buffer->destroy(surface->buffer);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
- }
-
return VA_STATUS_SUCCESS;
}
@@ -579,6 +567,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
int memory_type;
int expected_fourcc;
VAStatus vaStatus;
+ vlVaSurface *surf;
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -688,9 +677,11 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
mtx_lock(&drv->mutex);
for (i = 0; i < num_surfaces; i++) {
- vlVaSurface *surf = CALLOC(1, sizeof(vlVaSurface));
- if (!surf)
+ surf = CALLOC(1, sizeof(vlVaSurface));
+ if (!surf) {
+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
goto no_res;
+ }
surf->templat = templat;
@@ -706,33 +697,44 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
surf->buffer = drv->pipe->create_video_buffer(drv->pipe, &templat);
if (!surf->buffer) {
- FREE(surf);
- goto no_res;
+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+ goto free_surf;
}
- util_dynarray_init(&surf->subpics);
- surfaces[i] = handle_table_add(drv->htab, surf);
break;
+
case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME:
- vaStatus = suface_from_external_memory(ctx, surf, memory_attibute, i, surfaces, &templat);
- if (vaStatus != VA_STATUS_SUCCESS) {
- FREE(surf);
- goto no_res;
- }
+ vaStatus = suface_from_external_memory(ctx, surf, memory_attibute, i, &templat);
+ if (vaStatus != VA_STATUS_SUCCESS)
+ goto free_surf;
break;
+
default:
assert(0);
}
+
+ util_dynarray_init(&surf->subpics);
+ surfaces[i] = handle_table_add(drv->htab, surf);
+ if (!surfaces[i]) {
+ vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
+ goto destroy_surf;
+ }
}
mtx_unlock(&drv->mutex);
return VA_STATUS_SUCCESS;
+destroy_surf:
+ surf->buffer->destroy(surf->buffer);
+
+free_surf:
+ FREE(surf);
+
no_res:
mtx_unlock(&drv->mutex);
if (i)
vlVaDestroySurfaces(ctx, surfaces, i);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ return vaStatus;
}
VAStatus