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

Message ID 20201006144432.22908-14-jacopo@jmondi.org
State Accepted
Headers show
Series
  • CameraStream refactor
Related show

Commit Message

Jacopo Mondi Oct. 6, 2020, 2:44 p.m. UTC
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.

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

Comments

Kieran Bingham Oct. 6, 2020, 8:05 p.m. UTC | #1
Hi Jacopo,

On 06/10/2020 15:44, Jacopo Mondi wrote:
> 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.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Sounds good to me too. I see any reconfiguration already clears down the
streams, so indeed this looks good.

Reviewed-by: Kieran Bingham <kieran.bingham@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 58a9f44db219..8da70e817b46 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();
>  
>
Umang Jain Oct. 7, 2020, 8:08 a.m. UTC | #2
Hi jacopo

On 10/6/20 8:14 PM, Jacopo Mondi wrote:
> 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.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <email@uajain.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 58a9f44db219..8da70e817b46 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 58a9f44db219..8da70e817b46 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();