android: CameraDevice: Take shared_ptr in constructor

CameraDevice takes the ownership of Camera. Therefore,
shared_ptr would rather be used than const shared_ptr&.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2021-03-24 16:07:53 +09:00 committed by Laurent Pinchart
parent 1636d4c438
commit 9538ce4cc6
2 changed files with 9 additions and 7 deletions

View file

@ -312,9 +312,10 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()
* back to the framework using the designated callbacks.
*/
CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)
: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),
facing_(CAMERA_FACING_FRONT), orientation_(0)
CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera)
: id_(id), running_(false), camera_(std::move(camera)),
staticMetadata_(nullptr), facing_(CAMERA_FACING_FRONT),
orientation_(0)
{
camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
@ -351,9 +352,10 @@ CameraDevice::~CameraDevice()
}
std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,
const std::shared_ptr<Camera> &cam)
std::shared_ptr<Camera> cam)
{
return std::unique_ptr<CameraDevice>(new CameraDevice(id, cam));
return std::unique_ptr<CameraDevice>(
new CameraDevice(id, std::move(cam)));
}
/*