From patchwork Wed Mar 24 07:07:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11675 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 4E902C32E7 for ; Wed, 24 Mar 2021 07:08:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 91D4468D6A; Wed, 24 Mar 2021 08:08:13 +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="BczBPItg"; dkim-atps=neutral Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 01D8268D47 for ; Wed, 24 Mar 2021 08:08:11 +0100 (CET) Received: by mail-pg1-x52e.google.com with SMTP id h25so14019064pgm.3 for ; Wed, 24 Mar 2021 00:08:11 -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=8UxSnCmuALU/9Iixyz403NuafshZ1iLwjXQZHaAz1qI=; b=BczBPItgSO4JK9rUgzbCyHZu0YF8FnFbtaI9aHj4pFKmPbhRRaysnSxbRMMOlMESX8 MdEnRtaYYIevmKgJowH7qhQWNm9HgPk2LOTf2/aUqUnKtdzMp37jZ6SuRTl7ink1hCnO Bc/xzTimASPDj4i7z5sjZ0P+KPd3Ufiayn+7A= 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=8UxSnCmuALU/9Iixyz403NuafshZ1iLwjXQZHaAz1qI=; b=LGSEqQI6Eyk1NYMZSl08m/IEX1NkxYGN9wfswZ0UdM10H6gYLWY+27S6HxfnRzPSHQ pNXgLITboYLYqIF30pYHfnp83Q5Ls731bGyuBFDi3lKvlM83w4+dFBJADH1QwMvlLLCz wNCbxqZKqaNEm+uwf63H5WQpdBsiKCeDH+boHXD9cNoMriYAXXsVOOB81pw4ETwGmjrl S1ta6ZptwgtKNSAdvsYFH4McZd7kVSd/LT+H4IlllcksChnDGJ2JsYy2izEorQnXD1zX 0wjsDMukvn0kSXoUl7gNRVqac7MJhom3z3ng14VpoT0t7P4Y+hTAfmj7lMLa9VDjEGfG rdZA== X-Gm-Message-State: AOAM532a84WYx/HR9P0HZmXW3x0mDmVqPDf4dna6HcgyYl+EvZil9kpq cixuMIE4fKc/lIt3Sc1czP96zP29XG4MJQ== X-Google-Smtp-Source: ABdhPJxkdEYzpW4OvjM0vRRO16oRKNecM0nNlI5wFq3BmvWuxYxf5yBPLEs3U1MCiDEhXgmXJk2sPg== X-Received: by 2002:a63:c646:: with SMTP id x6mr1947334pgg.126.1616569687626; Wed, 24 Mar 2021 00:08:07 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:7c07:24cd:c637:7fab]) by smtp.gmail.com with ESMTPSA id e63sm1246860pfe.208.2021.03.24.00.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 00:08:07 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Mar 2021 16:07:51 +0900 Message-Id: <20210324070757.3530377-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210324070757.3530377-1-hiroh@chromium.org> References: <20210324070757.3530377-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/8] android: CameraHalManager: Hold CameraManager with std::unique_ptr 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" CameraManager is owned by CameraHalManager. The ownership of the object is not shared with other classes. So CameraHalManager should manage CameraManager with std::unique_ptr. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_hal_manager.cpp | 15 ++++----------- src/android/camera_hal_manager.h | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) -- 2.31.0.291.g576ba9dcdaf-goog diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index b3c85406..b501f8db 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -34,18 +34,12 @@ CameraHalManager::CameraHalManager() { } -CameraHalManager::~CameraHalManager() -{ - if (cameraManager_) { - cameraManager_->stop(); - delete cameraManager_; - cameraManager_ = nullptr; - } -} +/* CameraManager calls stop() in the destructor. */ +CameraHalManager::~CameraHalManager() = default; int CameraHalManager::init() { - cameraManager_ = new CameraManager(); + cameraManager_ = std::make_unique(); /* Support camera hotplug. */ cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded); @@ -55,8 +49,7 @@ int CameraHalManager::init() if (ret) { LOG(HAL, Error) << "Failed to start camera manager: " << strerror(-ret); - delete cameraManager_; - cameraManager_ = nullptr; + cameraManager_.reset(); return ret; } diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h index 65bb3554..dc4e37e5 100644 --- a/src/android/camera_hal_manager.h +++ b/src/android/camera_hal_manager.h @@ -47,7 +47,7 @@ private: CameraDevice *cameraDeviceFromHalId(unsigned int id); - libcamera::CameraManager *cameraManager_; + std::unique_ptr cameraManager_; const camera_module_callbacks_t *callbacks_; std::vector> cameras_;