From patchwork Tue Mar 23 01:42:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11649 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 17BACC32E1 for ; Tue, 23 Mar 2021 01:42:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB4BC68D66; Tue, 23 Mar 2021 02:42:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="avg53zh9"; dkim-atps=neutral Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5041A6084F for ; Tue, 23 Mar 2021 02:42:43 +0100 (CET) Received: by mail-pj1-x1031.google.com with SMTP id w8so9372532pjf.4 for ; Mon, 22 Mar 2021 18:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9SsannRWX5zE+DBPjpFdYVxvGcaefXukUFwOVlU+/EA=; b=avg53zh96onRkxS6ny1mMHN0pYgjwImD5tCglZHwDG3Ezg7MZf2VLNbT3NXagg2hcL z0WkLY37p2RMY6BCcFSTGirYxxY4LW6WkM1tE5k6Nf3oYQv/sxz/Gh75VtpHqhneR6Y/ 1ZojvAoTDb3FoO2GTh1pmUPTppmcMYESrtErM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9SsannRWX5zE+DBPjpFdYVxvGcaefXukUFwOVlU+/EA=; b=K2dr7cRUJc3e6RXuLHZ2paasQn7+AQkrNUEtc9+h9hvlIYXWaenuc2uRRzqWaQt6oL EGlmvNypT74YK1XGOObsWKFkLkm3TnHuTv3dTg6oaQ9Dql6EYZ0DH523Db6R9RbLDnx9 j9dbBQD6k81AR1wyirmmkhJc8trnHZ0zcHiDxTirq2Sra4GcgLxvrWowuJuBdCfgPXnX k3LOnWJW5DQKcw1BqsN2xGSh9V1iA2ufG7i1bimzyHXn5iiMHtW5eqGW7wdSnf+dmNNV jbbGZCP7eSyQvjnJ4EWMl4er8D/xkYfz/WDNcx0IngwtbbMYM1yiVDQ1Q7M52ab8H+Zf RxPA== X-Gm-Message-State: AOAM532vdtkPEAuBXdOdNTJFWmClcRt4qv0jCMrEa4YYtl1JbtEsz2bE wpbAuwcMwjiNP7d1Gy5OGJDtzy5bUIi4IQ== X-Google-Smtp-Source: ABdhPJwQ5W1S6LkZh8yagkiGusvLma9LvY7d2p94QwHN/9JzkAkhAZHiaL5kHXEu20PIROJKvap81g== X-Received: by 2002:a17:90a:a414:: with SMTP id y20mr1860919pjp.77.1616463761774; Mon, 22 Mar 2021 18:42:41 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:8115:e5cc:747b:64de]) by smtp.gmail.com with ESMTPSA id h13sm590527pjv.52.2021.03.22.18.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 18:42:41 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 10:42:22 +0900 Message-Id: <20210323014226.3211412-5-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210323014226.3211412-1-hiroh@chromium.org> References: <20210323014226.3211412-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/8] android: CameraDevice: Take shared_ptr in constructor X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" CameraDevice takes the ownership of Camera. Therefore, shared_ptr would rather be used than const shared_ptr&. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 12 +++++++----- src/android/camera_device.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) -- 2.31.0.rc2.261.g7f71774620-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d0955de7..c0630e53 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -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) - : id_(id), running_(false), camera_(camera), staticMetadata_(nullptr), - facing_(CAMERA_FACING_FRONT), orientation_(0) +CameraDevice::CameraDevice(unsigned int id, std::shared_ptr 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::create(unsigned int id, - const std::shared_ptr &cam) + std::shared_ptr cam) { - return std::unique_ptr(new CameraDevice(id, cam)); + return std::unique_ptr( + new CameraDevice(id, std::move(cam))); } /* diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 8be7f305..555b33e7 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -33,7 +33,7 @@ class CameraDevice : protected libcamera::Loggable { public: static std::unique_ptr create(unsigned int id, - const std::shared_ptr &cam); + std::shared_ptr cam); ~CameraDevice(); int initialize(); @@ -66,7 +66,7 @@ protected: std::string logPrefix() const override; private: - CameraDevice(unsigned int id, const std::shared_ptr &camera); + CameraDevice(unsigned int id, std::shared_ptr camera); struct Camera3RequestDescriptor { Camera3RequestDescriptor(libcamera::Camera *camera,