From patchwork Tue Mar 23 01:42:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11647 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 BB602C32E1 for ; Tue, 23 Mar 2021 01:42:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1852968D68; Tue, 23 Mar 2021 02:42:42 +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="E5j6sWSC"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B2A9A6084F for ; Tue, 23 Mar 2021 02:42:40 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id y200so12604386pfb.5 for ; Mon, 22 Mar 2021 18:42:40 -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=lS3DA6l2AnNO2wp6Yf+lEL831G/077oi/y8UWQ5WLDU=; b=E5j6sWSCMt1lEdS3TW+gPleXW3K43DyoNuyfVW6Q+R3JaoWROfPKKw53pvIPHpUGqp Xujw8O5fwhc1UbwP4xBEOlFSx9pvS4mirVkwQwQ2PF0CfeMwVrVrtJDQ0wRRUzSzlkgi 8cevysQ8PQ9Ekaojkv7wz6W1SqKCbIUIxc2gM= 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=lS3DA6l2AnNO2wp6Yf+lEL831G/077oi/y8UWQ5WLDU=; b=h5nCerO3HxHmdLHPi0u8l/1PTcx+BfwqStd2AIWP3j3+QPNF9u0mcHKL4jb0ob45Ah TjzMPnv/u1u7XuhcBlVa/9z2+6aLV+/n+CL/hMEVtzkpP/S5g+IX7mgSm7LeUoAfWflT kAsrbTsNkSMP8OqA4lzfCTTN5T6HkQ2MSNUAEB7aJOWM8HD4Buz2Hqxc3fUtIEml63Sc bcB87dEyLuss2qu67tNgSo6rM/xgrpRSaLjLLb7YkXHD3NKjt4kLksIe+G86sQuMJ2DO knmOtbgVWpn+JUbEj4eYYlQnl8X0ZuuwOWXP7+gkFnJKfMhSbz3w7PYpiX7loY0FIvII VrVw== X-Gm-Message-State: AOAM530xwUExdBlWGS9JUV5lFZM+DWua8wGBJ+iRUSOzQ6GtWJnMtS0s NmThBCUatTSlAu0qtlbUWbyF1K2cMycyxQ== X-Google-Smtp-Source: ABdhPJw2FFs36zpi4+yipP1aTF8/0zuj9VpwwpKOmGffJRh/xfNhUVpu8V9oe3dIUZeAvMkhtCUFPQ== X-Received: by 2002:a65:5585:: with SMTP id j5mr1918658pgs.316.1616463759015; Mon, 22 Mar 2021 18:42:39 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 18:42:38 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 10:42:20 +0900 Message-Id: <20210323014226.3211412-3-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 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 --- src/android/camera_hal_manager.cpp | 14 +++----------- src/android/camera_hal_manager.h | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) -- 2.31.0.rc2.261.g7f71774620-goog diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index b3c85406..fa398fea 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -34,18 +34,11 @@ CameraHalManager::CameraHalManager() { } -CameraHalManager::~CameraHalManager() -{ - if (cameraManager_) { - cameraManager_->stop(); - delete cameraManager_; - cameraManager_ = nullptr; - } -} +CameraHalManager::~CameraHalManager() = default; int CameraHalManager::init() { - cameraManager_ = new CameraManager(); + cameraManager_ = std::make_unique(); /* Support camera hotplug. */ cameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded); @@ -55,8 +48,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_;