diff options
author | Hirokazu Honda <hiroh@chromium.org> | 2021-04-03 22:57:34 +0900 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-04-20 05:59:08 +0300 |
commit | d40430116b1b65d8deeeeea106368e20d8534a03 (patch) | |
tree | 02e20a38f4307f7f701b7d6ead58fa168f238937 /src/android/camera_device.h | |
parent | 0b661d70ec62d69ffd4ea7bb0aeb92d7ad12b8d3 (diff) |
android: CameraDevice: Fix Camera3RequestDescriptor leakage
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>
Diffstat (limited to 'src/android/camera_device.h')
-rw-r--r-- | src/android/camera_device.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 39cf95ad..c63e8e21 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -9,6 +9,7 @@ #include <map> #include <memory> +#include <mutex> #include <tuple> #include <vector> @@ -69,11 +70,13 @@ private: CameraDevice(unsigned int id, std::shared_ptr<libcamera::Camera> camera); struct Camera3RequestDescriptor { + Camera3RequestDescriptor() = default; + ~Camera3RequestDescriptor() = default; Camera3RequestDescriptor(libcamera::Camera *camera, const camera3_capture_request_t *camera3Request); - ~Camera3RequestDescriptor(); + Camera3RequestDescriptor &operator=(Camera3RequestDescriptor &&) = default; - uint32_t frameNumber_; + uint32_t frameNumber_ = 0; std::vector<camera3_stream_buffer_t> buffers_; std::vector<std::unique_ptr<libcamera::FrameBuffer>> frameBuffers_; CameraMetadata settings_; @@ -124,6 +127,9 @@ private: std::map<int, libcamera::PixelFormat> formatsMap_; std::vector<CameraStream> streams_; + std::mutex mutex_; /* Protect descriptors_ */ + std::map<uint64_t, Camera3RequestDescriptor> descriptors_; + std::string maker_; std::string model_; |