[libcamera-devel,v4,4/9] android: camera_device: Clear allocator

Message ID 20200930132707.19367-5-jacopo@jmondi.org
State Superseded
Headers show
Series
  • android: camera_device: Add support for internal buffers
Related show

Commit Message

Jacopo Mondi Sept. 30, 2020, 1:27 p.m. UTC
Clear all the allocated buffers at camera close() time and before
configuring the camera streams at configureStream() time as the
configureStream operation could be called by the Android framework
in two successive capture sessions without going through a close().

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index d8587647f831..d73d10d9d449 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -534,6 +534,8 @@  int CameraDevice::open(const hw_module_t *hardwareModule)
 
 void CameraDevice::close()
 {
+	allocator_.freeAll();
+
 	camera_->stop();
 	camera_->release();
 
@@ -1181,12 +1183,13 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 	}
 
 	/*
-	 * Clear and remove any existing configuration from previous calls, and
-	 * ensure the required entries are available without further
-	 * reallocation.
+	 * Clear and remove any existing configuration and memory allocated from
+	 * previous calls, and ensure the required entries are available without
+	 * further reallocation.
 	 */
 	streams_.clear();
 	streams_.reserve(stream_list->num_streams);
+	allocator_.freeAll();
 
 	/* First handle all non-MJPEG streams. */
 	camera3_stream_t *jpegStream = nullptr;