context: Liberate output and capture buffers at ContextDestroy
The V4L2 API does not currently provide a way to liberate allocated buffers one by one (which would fit well with DestroySurfaces in VAAPI). Moreover, streaming needs to be off before liberating buffers is allowed. As a result, output an capture buffers can only be liberated when destroying the decoding context, all at once, such as implemented in this patch. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
This commit is contained in:
+23
-3
@@ -196,15 +196,13 @@ VAStatus RequestDestroyContext(VADriverContextP context, VAContextID context_id)
|
||||
{
|
||||
struct request_data *driver_data = context->pDriverData;
|
||||
struct object_context *context_object;
|
||||
VAStatus status;
|
||||
int rc;
|
||||
|
||||
context_object = CONTEXT(driver_data, context_id);
|
||||
if (context_object == NULL)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
object_heap_free(&driver_data->context_heap,
|
||||
(struct object_base *)context_object);
|
||||
|
||||
rc = v4l2_set_stream(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, false);
|
||||
if (rc < 0)
|
||||
@@ -215,5 +213,27 @@ VAStatus RequestDestroyContext(VADriverContextP context, VAContextID context_id)
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
/* Buffers liberation */
|
||||
|
||||
status = RequestDestroySurfaces(context, context_object->surfaces_ids,
|
||||
context_object->surfaces_count);
|
||||
if (status != VA_STATUS_SUCCESS)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
free(context_object->surfaces_ids);
|
||||
|
||||
object_heap_free(&driver_data->context_heap,
|
||||
(struct object_base *)context_object);
|
||||
|
||||
rc = v4l2_request_buffers(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, 0);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
rc = v4l2_request_buffers(driver_data->video_fd,
|
||||
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, 0);
|
||||
if (rc < 0)
|
||||
return VA_STATUS_ERROR_OPERATION_FAILED;
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user