diff options
author | Umang Jain <umang.jain@ideasonboard.com> | 2021-09-24 18:35:59 +0530 |
---|---|---|
committer | Umang Jain <umang.jain@ideasonboard.com> | 2021-09-28 13:20:17 +0530 |
commit | 7f035328fb8acd90f655a632c4e102294da3b39a (patch) | |
tree | 0e89ca69cda48287f3f8f0c17115e3904777d480 /src | |
parent | 03c9b1a0a47b4210154b560c9533eedd1a2aeea3 (diff) |
android: camera_device: Fix race on queuing capture request
The Camera3RequestDescriptor containing the capture request is added to
the descriptors_ map after a call to CameraWorker::queueRequest(). This
is a race condition since CameraWorker::queueRequest() queues requests
to libcamera::Camera asynchronously. The requests may thus complete
before they get added to descriptors_, in which case requestComplete()
will fail to lookup the request in the map.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/camera_device.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 21844e51..ab381168 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1065,13 +1065,15 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques state_ = State::Running; } - worker_.queueRequest(descriptor.request_.get()); + CaptureRequest *request = descriptor.request_.get(); { MutexLocker descriptorsLock(descriptorsMutex_); descriptors_[descriptor.request_->cookie()] = std::move(descriptor); } + worker_.queueRequest(request); + return 0; } |