[libcamera-devel,15/15] android: camera_device: Clear streams_ at stop time

Message ID 20201005104649.10812-16-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • CameraStream refactoring
Related show

Commit Message

Laurent Pinchart Oct. 5, 2020, 10:46 a.m. UTC
From: Jacopo Mondi <jacopo@jmondi.org>

When the CameraDevice is stopped, we need to clear the vector
of CameraStream instances to make sure they get deleted and all the
resources they have acquired get released.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/android/camera_device.cpp | 2 ++
 1 file changed, 2 insertions(+)

Comments

Laurent Pinchart Oct. 5, 2020, 12:44 p.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Mon, Oct 05, 2020 at 01:46:49PM +0300, Laurent Pinchart wrote:
> From: Jacopo Mondi <jacopo@jmondi.org>
> 
> When the CameraDevice is stopped, we need to clear the vector
> of CameraStream instances to make sure they get deleted and all the
> resources they have acquired get released.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/android/camera_device.cpp | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 1a9af2e34340..6bbdfcc4a28b 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -517,6 +517,8 @@ int CameraDevice::open(const hw_module_t *hardwareModule)
>  
>  void CameraDevice::close()
>  {
> +	streams_.clear();
> +
>  	camera_->stop();
>  	camera_->release();
>

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 1a9af2e34340..6bbdfcc4a28b 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -517,6 +517,8 @@  int CameraDevice::open(const hw_module_t *hardwareModule)
 
 void CameraDevice::close()
 {
+	streams_.clear();
+
 	camera_->stop();
 	camera_->release();