From patchwork Tue Mar 23 01:42:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11652 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 E848AC32E1 for ; Tue, 23 Mar 2021 01:42:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A9F1868D7B; Tue, 23 Mar 2021 02:42:50 +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="EDY3hIMN"; dkim-atps=neutral Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8066C68D65 for ; Tue, 23 Mar 2021 02:42:47 +0100 (CET) Received: by mail-pf1-x435.google.com with SMTP id y5so12615288pfn.1 for ; Mon, 22 Mar 2021 18:42:47 -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=F25CpZfGZLc+v5dCL7KCeC8aHDszpv2/2eWqJl9POf0=; b=EDY3hIMNm9LqByu5VcmalbQeDZyjWPonen58qCk0vwi0HCM7/zc/SCLu4KLgkLxY6E LIgiQsk5mHFNPSowdRqU36WooUkXuP2LEKdVq/U0FuEexBUkEro3SwCKum/I3JFBPdqE ITygNqg5tQtnBlR2bXDHVo3JHJtjVH/rN7C3g= 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=F25CpZfGZLc+v5dCL7KCeC8aHDszpv2/2eWqJl9POf0=; b=OQqk9+lEZ3GYuLuWyEKZRjtIyO/jd+KAg1S9DPzrPDOyEmYns2y3+H9+gMppTXJU0a 0er8ZHytGtRycR0yeTx9oMghTS3Fybj866E2gUn88Z8AZ92Ktw1thGa18UHlJNqWl+rG 5O2Om7Rvmufw9crGdMweoyXbFOzVcoKESXatjBc91wlqwyVxEXDsYSJNF9umWFjNOJ09 SI1FDBxhGYnGO0SlZtQ8F3MQVBtQuy5Ynv7B0RIz1tglF4JMsZLF+3mxCg/tst5JAjwl G/Pxj9ptmWLL7IEw7rVoC51SXZe+eGlGoQvVOXJYh3XolkxwvM7w1bsro4rEczwPq4cf aBYA== X-Gm-Message-State: AOAM530q0qTzEx4zUGow6OfOl4pZ2fU6zqbvJp+NZixAOaWHS/3zVxFk vsj3oaSvQ4aMpaY0eVebXmEHOFxQXqWRHg== X-Google-Smtp-Source: ABdhPJyc9HNEdU/yZx4lg6z1PnUfjsam4O/NK8nY227mldE2nofgn+r5rrrDJATp7x3ur9/tXzT9sg== X-Received: by 2002:a62:7708:0:b029:1ee:f656:51d5 with SMTP id s8-20020a6277080000b02901eef65651d5mr2509873pfc.59.1616463766003; Mon, 22 Mar 2021 18:42:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 18:42:45 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 10:42:25 +0900 Message-Id: <20210323014226.3211412-8-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 7/8] android: CameraDevice: Manage staticMetadata_ 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" Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 14 ++++---------- src/android/camera_device.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) -- 2.31.0.rc2.261.g7f71774620-goog diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index b000d332..696f7676 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -311,8 +311,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor() = default; 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) + facing_(CAMERA_FACING_FRONT), orientation_(0) { camera_->requestCompleted.connect(this, &CameraDevice::requestComplete); @@ -341,9 +340,6 @@ CameraDevice::CameraDevice(unsigned int id, std::shared_ptr camera) CameraDevice::~CameraDevice() { - if (staticMetadata_) - delete staticMetadata_; - for (auto &it : requestTemplates_) delete it.second; } @@ -732,11 +728,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() uint32_t numEntries; uint32_t byteSize; std::tie(numEntries, byteSize) = calculateStaticMetadataSize(); - staticMetadata_ = new CameraMetadata(numEntries, byteSize); + staticMetadata_ = std::make_unique(numEntries, byteSize); if (!staticMetadata_->isValid()) { LOG(HAL, Error) << "Failed to allocate static metadata"; - delete staticMetadata_; - staticMetadata_ = nullptr; + staticMetadata_.reset(); return nullptr; } @@ -1356,8 +1351,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() if (!staticMetadata_->isValid()) { LOG(HAL, Error) << "Failed to construct static metadata"; - delete staticMetadata_; - staticMetadata_ = nullptr; + staticMetadata_.reset(); return nullptr; } diff --git a/src/android/camera_device.h b/src/android/camera_device.h index a11cf243..cea82b24 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -113,7 +113,7 @@ private: std::shared_ptr camera_; std::unique_ptr config_; - CameraMetadata *staticMetadata_; + std::unique_ptr staticMetadata_; std::map requestTemplates_; const camera3_callback_ops_t *callbacks_;