[libcamera-devel] [PATCH v4 5/8] android: camera_device: Create the Request and Camera3RequestDescriptor together
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Jul 6 17:38:05 CEST 2020
Move the construction of the Request higher in the code flow so that
multiple buffers and streams can be added where required.
The Request is now stored as a unique_ptr within the
Camera3RequestDescriptor to enforce a shared lifetime between the
objects, freeing the Request when the descriptor is destroyed.
Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 9 ++++++---
src/android/camera_device.h | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 73cfab532cf5..fb120e8007dc 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1066,6 +1066,12 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
Camera3RequestDescriptor *descriptor =
new Camera3RequestDescriptor(camera3Request->frame_number,
camera3Request->num_output_buffers);
+
+ Request *request =
+ camera_->createRequest(reinterpret_cast<uint64_t>(descriptor));
+
+ descriptor->request = std::unique_ptr<Request>(request);
+
for (unsigned int i = 0; i < descriptor->numBuffers; ++i) {
/*
* Keep track of which stream the request belongs to and store
@@ -1089,14 +1095,11 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
return -ENOMEM;
}
- Request *request =
- camera_->createRequest(reinterpret_cast<uint64_t>(descriptor));
request->addBuffer(stream, buffer);
int ret = camera_->queueRequest(request);
if (ret) {
LOG(HAL, Error) << "Failed to queue request";
- delete request;
delete descriptor;
return ret;
}
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index d7834d94f439..018491d70c0a 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -61,6 +61,7 @@ private:
uint32_t frameNumber;
uint32_t numBuffers;
camera3_stream_buffer_t *buffers;
+ std::unique_ptr<libcamera::Request> request;
};
struct Camera3StreamConfiguration {
--
2.25.1
More information about the libcamera-devel
mailing list