android: Pass Camera shared pointer to CameraProxy by const reference

The CameraProxy is constructed with a Camera instance passed through a
shared pointer. It forwards it to the CameraDevice constructor, which
takes a reference used for the sole purpose of making an internal copy
of the shared pointer. Both constructors can thus take a const reference
instead of a value or a mutable reference. This optimises the
constructors slightly.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart 2019-08-18 01:45:01 +03:00
parent 5ce4bb62e7
commit 0ed40d2cd4
4 changed files with 4 additions and 4 deletions

View file

@ -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)
{

View file

@ -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);

View file

@ -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);

View file

@ -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);