[libcamera-devel] [PATCH 09/14] android: Pass Camera shared pointer to CameraDevice by const reference

Jacopo Mondi jacopo at jmondi.org
Mon Aug 19 11:06:15 CEST 2019


Hi Laurent,

On Sun, Aug 18, 2019 at 04:13:24AM +0300, Laurent Pinchart wrote:
> The CameraDevice is constructed with a Camera instance passed through a

It's actually the CameraProxy that receives the camera parameter by
value to then pass it to the CameraDevice constructor, which already
takes a reference.

Apart from this
Reviewed-by: Jacopo Mondi <jacopo at jmondi.org>

Thanks
  j

> shared pointer. It makes an internal copy of the pointer, which can be
> passed by const reference instead of value. This optimises the
> constructor slightly.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/android/camera_device.cpp | 2 +-
>  src/android/camera_device.h   | 2 +-
>  src/android/camera_proxy.cpp  | 2 +-
>  src/android/camera_proxy.h    | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 999c51e6ba4a..9acfed694abc 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -49,7 +49,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()
>   * to the framework using the designated callbacks.
>   */
>
> -CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> &camera)
> +CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)
>  	: running_(false), camera_(camera), staticMetadata_(nullptr),
>  	  requestTemplate_(nullptr)
>  {
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 4d834ceb08a5..7897ba9dc5c7 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -31,7 +31,7 @@ class ThreadRpc;
>  class CameraDevice : public libcamera::Object
>  {
>  public:
> -	CameraDevice(unsigned int id, std::shared_ptr<libcamera::Camera> &camera);
> +	CameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
>  	~CameraDevice();
>
>  	void call(ThreadRpc *rpc);
> diff --git a/src/android/camera_proxy.cpp b/src/android/camera_proxy.cpp
> index 3eb2f9fbcffb..4f5c0a024903 100644
> --- a/src/android/camera_proxy.cpp
> +++ b/src/android/camera_proxy.cpp
> @@ -113,7 +113,7 @@ static camera3_device_ops hal_dev_ops = {
>  	.reserved = { nullptr },
>  };
>
> -CameraProxy::CameraProxy(unsigned int id, std::shared_ptr<Camera> camera)
> +CameraProxy::CameraProxy(unsigned int id, const std::shared_ptr<Camera> &camera)
>  	: id_(id)
>  {
>  	cameraDevice_ = new CameraDevice(id, camera);
> diff --git a/src/android/camera_proxy.h b/src/android/camera_proxy.h
> index da63bfa79fc9..7940eac4e376 100644
> --- a/src/android/camera_proxy.h
> +++ b/src/android/camera_proxy.h
> @@ -19,7 +19,7 @@ class ThreadRpc;
>  class CameraProxy
>  {
>  public:
> -	CameraProxy(unsigned int id, std::shared_ptr<libcamera::Camera> camera);
> +	CameraProxy(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);
>  	~CameraProxy();
>
>  	int open(const hw_module_t *hardwareModule);
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20190819/bd3280ff/attachment.sig>


More information about the libcamera-devel mailing list