[libcamera-devel,4/8] android: camera_device: Clear allocator at configureStream

Message ID 20200909155457.153907-5-jacopo@jmondi.org
State Superseded
Headers show
Series
  • android: camera_device: Allocate internal buffers
Related show

Commit Message

Jacopo Mondi Sept. 9, 2020, 3:54 p.m. UTC
The configureStream operation might be called by the Android framework
in two successive capture session without going through a close().

Clear all the allocated buffers before configuring the camera streams.

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

Comments

Niklas Söderlund Sept. 10, 2020, 11:20 a.m. UTC | #1
Hi Jacopo,

Thanks for your patch.

On 2020-09-09 17:54:53 +0200, Jacopo Mondi wrote:
> The configureStream operation might be called by the Android framework
> in two successive capture session without going through a close().
> 
> Clear all the allocated buffers before configuring the camera streams.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/android/camera_device.cpp | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 98cfa3d5aa59..d35c6b93b654 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -1187,6 +1187,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
>  	 */
>  	streams_.clear();
>  	streams_.reserve(stream_list->num_streams);
> +	allocator_.clear();
>  
>  	/* First handle all non-MJPEG streams. */
>  	camera3_stream_t *jpegStream = nullptr;
> -- 
> 2.28.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Hirokazu Honda Sept. 11, 2020, 7:37 a.m. UTC | #2
Hi Jacopo.
Thanks for your patch.

On Thu, Sep 10, 2020 at 8:20 PM Niklas Söderlund
<niklas.soderlund@ragnatech.se> wrote:
>
> Hi Jacopo,
>
> Thanks for your patch.
>
> On 2020-09-09 17:54:53 +0200, Jacopo Mondi wrote:
> > The configureStream operation might be called by the Android framework
> > in two successive capture session without going through a close().
> >
> > Clear all the allocated buffers before configuring the camera streams.
> >
> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
>
> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
>

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> > ---
> >  src/android/camera_device.cpp | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index 98cfa3d5aa59..d35c6b93b654 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -1187,6 +1187,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> >        */
> >       streams_.clear();
> >       streams_.reserve(stream_list->num_streams);
> > +     allocator_.clear();
> >
> >       /* First handle all non-MJPEG streams. */
> >       camera3_stream_t *jpegStream = nullptr;
> > --
> > 2.28.0
> >
> > _______________________________________________
> > libcamera-devel mailing list
> > libcamera-devel@lists.libcamera.org
> > https://lists.libcamera.org/listinfo/libcamera-devel
>
> --
> Regards,
> Niklas Söderlund
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 98cfa3d5aa59..d35c6b93b654 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1187,6 +1187,7 @@  int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
 	 */
 	streams_.clear();
 	streams_.reserve(stream_list->num_streams);
+	allocator_.clear();
 
 	/* First handle all non-MJPEG streams. */
 	camera3_stream_t *jpegStream = nullptr;