summaryrefslogtreecommitdiff
path: root/src/android/camera_worker.cpp
AgeCommit message (Collapse)Author
2021-05-31android: Don't rely on indirect inclusion of unistd.hLaurent Pinchart
The standard C library close() and lseek() functions require inclusion of the unistd.h header. Include it explicitly where needed instead of relying on indirect inclusion. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
2021-05-24android: camera_worker: Process all queued requests when stoppingLaurent Pinchart
When stopping the camera worker, queuedRequest() calls may have queued asynchronous function invocation messages to the worker thread, and some of those messages may not have been processed yet. The messages will stay in the thread's queue until the camera worker is restarted (when the camera service will start a new capture session). At that point, they will be dispatched, which will cause a crash due to the CaptureRequest passed to processRequest() having been deleted by CameraDevice::stop() calling descriptors_.clear(). Fix this by forcing dispatching of all function invocation messages when stopping the camera worker thread. Note that this is inherently racy, as more queueRequest() calls may arrive from the camera service while we're stopping. This race condition will be addressed by a subsequent patch series. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-04-20android: CameraDevice: Fix Camera3RequestDescriptor leakageHirokazu Honda
CameraDevice creates Camera3RequestDescriptor in processCaptureRequest() and disallocates in requestComplete(). Camera3RequestDescriptor can never be destroyed if requestComplete() is never called. This avoid the memory leakage by storing them in map CameraRequestDescriptor. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-20android: Omit extra semicolonsHirokazu Honda
The end semicolons with LOG_DECLARE_CATEGORY and LOG_DEFINE_CATEGORY are unnecessary. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-10-14android: camera_worker: Introduce CameraWorkerJacopo Mondi
The Android camera framework provides for each buffer part of a capture request an acquisition fence the camera HAL is supposed to wait on before using the buffer. As the libcamera HAL runs in the camera service thread, it is not possible to perform a synchronous wait there. Introduce a CameraWorker class that runs an internal thread to wait on a set of fences before queueing a capture request to the libcamera::Camera. Fences completion is handled through a simple poll, similar in implementation to the sync_wait() function provided by libdrm. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>