diff options
author | Paul Kocialkowski <paul.kocialkowski@bootlin.com> | 2018-07-19 15:07:43 +0200 |
---|---|---|
committer | Paul Kocialkowski <paul.kocialkowski@bootlin.com> | 2018-07-20 13:47:48 +0200 |
commit | fa7ab6a25148e3beeef6977daeb7dd2566b9c448 (patch) | |
tree | bc457f43c9b7dcc4e9545fdb7b1d8c2a58992713 /src | |
parent | 72c22a3bcea891bfe7947bbd96108ff418b6464d (diff) | |
download | libva-v4l2-request-fa7ab6a25148e3beeef6977daeb7dd2566b9c448.tar.gz libva-v4l2-request-fa7ab6a25148e3beeef6977daeb7dd2566b9c448.tar.bz2 libva-v4l2-request-fa7ab6a25148e3beeef6977daeb7dd2566b9c448.zip |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/context.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/context.c b/src/context.c index 3c924c8..233bac6 100644 --- a/src/context.c +++ b/src/context.c @@ -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; } |