[libcamera-devel] [PATCH 08/15] android: camera_device: Return Camera as shared_ptr

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Oct 6 12:17:00 CEST 2020


Hi Jacopo,

On 05/10/2020 13:17, Laurent Pinchart wrote:
> Hi Jacopo,
> 
> Thank you for the patch.
> 
> On Mon, Oct 05, 2020 at 01:46:42PM +0300, Laurent Pinchart wrote:
>> From: Jacopo Mondi <jacopo at jmondi.org>
>>
>> Return the Camera wrapped by the CameraDevice as a shared_ptr.
>> This will be required to construct the FrameBuffer allocator in
>> the CameraStream class.

Sounds good to me.

>>
>> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
>> ---
>>  src/android/camera_device.h        | 2 +-
>>  src/android/camera_hal_manager.cpp | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
>> index 826023b453f7..777d1a35e801 100644
>> --- a/src/android/camera_device.h
>> +++ b/src/android/camera_device.h
>> @@ -49,7 +49,7 @@ public:
>>  
>>  	unsigned int id() const { return id_; }
>>  	camera3_device_t *camera3Device() { return &camera3Device_; }
>> -	const libcamera::Camera *camera() const { return camera_.get(); }
>> +	std::shared_ptr<libcamera::Camera> camera() const { return camera_; }
>>  	libcamera::CameraConfiguration *cameraConfiguration() const
>>  	{
>>  		return config_.get();
>> diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp
>> index 05b474010b1d..e29eddbb5590 100644
>> --- a/src/android/camera_hal_manager.cpp
>> +++ b/src/android/camera_hal_manager.cpp
>> @@ -155,7 +155,7 @@ void CameraHalManager::cameraRemoved(std::shared_ptr<Camera> cam)
>>  
>>  	auto iter = std::find_if(cameras_.begin(), cameras_.end(),
>>  				 [&cam](std::shared_ptr<CameraDevice> &camera) {
>> -					 return cam.get() == camera->camera();
>> +					 return cam.get() == camera->camera().get();
> 
> Maybe just return cam == camera->camera() ?
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

With the simplified comparison:

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

> 
>>  				 });
>>  	if (iter == cameras_.end())
>>  		return;
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list