[libcamera-devel] android: camera_device: Initialize 'id_' field in constructor

Message ID 20200805125343.116183-1-email@uajain.com
State Accepted
Commit 035ee23910233eabbdaed1469f3d329d66e0ead4
Headers show
Series
  • [libcamera-devel] android: camera_device: Initialize 'id_' field in constructor
Related show

Commit Message

Umang Jain Aug. 5, 2020, 12:53 p.m. UTC
A 'id' is passed when a new CameraDevice is constructed in order for
unique identification. Failing to initialize it,  will lead to the
issue of garbage return value via CameraDevice::id().

Signed-off-by: Umang Jain <email@uajain.com>
---
 src/android/camera_device.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Aug. 5, 2020, 1 p.m. UTC | #1
Hi Umang,

Thank you for the patch.

On Wed, Aug 05, 2020 at 12:53:49PM +0000, Umang Jain wrote:
> A 'id' is passed when a new CameraDevice is constructed in order for
> unique identification. Failing to initialize it,  will lead to the
> issue of garbage return value via CameraDevice::id().
> 
> Signed-off-by: Umang Jain <email@uajain.com>

Good catch.

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

> ---
>  src/android/camera_device.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index c1e5812..55057f9 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -163,7 +163,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()
>   */
>  
>  CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)
> -	: running_(false), camera_(camera), staticMetadata_(nullptr),
> +	: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),
>  	  facing_(CAMERA_FACING_FRONT), orientation_(0)
>  {
>  	camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
Kieran Bingham Aug. 6, 2020, 11:13 a.m. UTC | #2
Hi Umang,

On 05/08/2020 14:00, Laurent Pinchart wrote:
> Hi Umang,
> 
> Thank you for the patch.
> 
> On Wed, Aug 05, 2020 at 12:53:49PM +0000, Umang Jain wrote:
>> A 'id' is passed when a new CameraDevice is constructed in order for
>> unique identification. Failing to initialize it,  will lead to the
>> issue of garbage return value via CameraDevice::id().
>>
>> Signed-off-by: Umang Jain <email@uajain.com>
> 
> Good catch.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

I'll push this after testing locally.

--
Kieran


> 
>> ---
>>  src/android/camera_device.cpp | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
>> index c1e5812..55057f9 100644
>> --- a/src/android/camera_device.cpp
>> +++ b/src/android/camera_device.cpp
>> @@ -163,7 +163,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()
>>   */
>>  
>>  CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)
>> -	: running_(false), camera_(camera), staticMetadata_(nullptr),
>> +	: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),
>>  	  facing_(CAMERA_FACING_FRONT), orientation_(0)
>>  {
>>  	camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
>

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index c1e5812..55057f9 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -163,7 +163,7 @@  CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()
  */
 
 CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)
-	: running_(false), camera_(camera), staticMetadata_(nullptr),
+	: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),
 	  facing_(CAMERA_FACING_FRONT), orientation_(0)
 {
 	camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);