summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-09-23 19:05:41 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2020-10-12 11:32:40 +0900
commitc753223ad6b90550fae31aedd79fbedc13da2e75 (patch)
tree957c83eb734fbfc633fd3a0a39c8339695323fe4 /src/android
parent05cdef27ab766a199a256c73ef4b338ce4f4dac5 (diff)
libcamera, android, cam, gstreamer, qcam, v4l2: Reuse Request
Allow reuse of the Request object by implementing reuse(). This means the applications now have the responsibility of freeing the Request objects, so make all libcamera users (cam, qcam, v4l2-compat, gstreamer, android) do so. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/camera_device.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 0a94c1ae..c29fcb43 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1375,8 +1375,12 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
new Camera3RequestDescriptor(camera3Request->frame_number,
camera3Request->num_output_buffers);
- Request *request =
+ std::unique_ptr<Request> request =
camera_->createRequest(reinterpret_cast<uint64_t>(descriptor));
+ if (!request) {
+ LOG(HAL, Error) << "Failed to create request";
+ return -ENOMEM;
+ }
LOG(HAL, Debug) << "Queueing Request to libcamera with "
<< descriptor->numBuffers << " HAL streams";
@@ -1440,7 +1444,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
if (!buffer) {
LOG(HAL, Error) << "Failed to create buffer";
- delete request;
delete descriptor;
return -ENOMEM;
}
@@ -1448,14 +1451,16 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques
request->addBuffer(cameraStream->stream(), buffer);
}
- int ret = camera_->queueRequest(request);
+ int ret = camera_->queueRequest(request.get());
if (ret) {
LOG(HAL, Error) << "Failed to queue request";
- delete request;
delete descriptor;
return ret;
}
+ /* The request will be deleted in the completion handler. */
+ request.release();
+
return 0;
}
@@ -1559,6 +1564,7 @@ void CameraDevice::requestComplete(Request *request)
callbacks_->process_capture_result(callbacks_, &captureResult);
delete descriptor;
+ delete request;
}
std::string CameraDevice::logPrefix() const