From patchwork Wed Dec 1 07:07:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14928 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 23EACBF415 for ; Wed, 1 Dec 2021 07:07:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C3AFD6072A; Wed, 1 Dec 2021 08:07:41 +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="c1SjOnDc"; dkim-atps=neutral Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D3CA260727 for ; Wed, 1 Dec 2021 08:07:39 +0100 (CET) Received: by mail-pg1-x532.google.com with SMTP id 200so22646955pga.1 for ; Tue, 30 Nov 2021 23:07:39 -0800 (PST) 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=hri0Xm34PsgBbaDCXWbRIaQJpAoLrbjERv7g2d7844k=; b=c1SjOnDcOFtqXCE1AvevpQ4Xh0Y4+JEShEzKFl8GGXTE0O+FjZPi00+9NWMOQdUvTT WBNUEaoAmYrVmWuR/grq0+9ZL7If8GXQbw3eSkqvvD15AfeJIeRWBaO2+AtkQzS8U7nD S9aP+fZYrBlb6F+Zt9yBHskG8An2/OIjgQHzM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hri0Xm34PsgBbaDCXWbRIaQJpAoLrbjERv7g2d7844k=; b=SEkIKW15WZztG30Md0lFwXVhbWnSpsjvzY3ZTEbLaVynbMWzNc7XGY3GK1c8biyqat PyIcPaegB3KRKPvTjB8SkUgLmVoezhswOAI4XkZhIFOzmbSOchvftCxwU3iFBWI4/vqk 2vJN3WjHP0fKmsctglU1mGUnebh8Y5DM+dVURRQJD4X65jgx17ngCQO9iHfbRK8WyQRu iwR0OoK3sH+cAHeNAvfAMe2Y4R70e7HRfDeFOImkblLNd9V4aM8zefoQe+/n8juxxVMz tr4bl78GQkAjADEfpPD7WNgdQx1Wzpq5kUJpF55ie3mJc0Urw0yztaaygc6w7ZkI12WR 8K3A== X-Gm-Message-State: AOAM533N94Y3REnyKpwY7ksnov0D4lz1B9KQeL+M9Q2DBpLpJPX/YzuA LPMUpfaA7p0iwURu75cvHatDvjQkT2onYA== X-Google-Smtp-Source: ABdhPJyBKlz+/pz2ESJbqwspKMEKIrZ2bL9RfB87OPte43lNkLdF4ZJtt2lUEEWP/RDJ2KX1t2RfZg== X-Received: by 2002:a05:6a00:9a3:b0:49f:bf9b:3192 with SMTP id u35-20020a056a0009a300b0049fbf9b3192mr4175982pfg.44.1638342458092; Tue, 30 Nov 2021 23:07:38 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id m10sm16598962pgv.75.2021.11.30.23.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:07:37 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:07:18 +0900 Message-Id: <20211201070728.3114247-3-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201070728.3114247-1-hiroh@chromium.org> References: <20211201070728.3114247-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 02/12] android: Consolidate mutex classes to Mutex and MutexLocker 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" std::mutex and std::unique_lcok are used in android directories, mixing Mutex and MutexLocker. This consolidates them to Mutex and MutexLocker. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_device.h | 1 - src/android/camera_hal_manager.h | 7 ++----- src/android/camera_request.h | 4 ++-- src/android/camera_stream.cpp | 12 ++++++------ src/android/camera_stream.h | 3 +-- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 51fe7da2..bda0b376 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -9,7 +9,6 @@ #include #include -#include #include #include diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h index 192f2fc5..cc310f90 100644 --- a/src/android/camera_hal_manager.h +++ b/src/android/camera_hal_manager.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include #include @@ -18,6 +17,7 @@ #include #include +#include #include @@ -44,9 +44,6 @@ public: private: LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraHalManager) - using Mutex = std::mutex; - using MutexLocker = std::unique_lock; - static constexpr unsigned int firstExternalCameraId_ = 1000; CameraHalManager(); @@ -64,7 +61,7 @@ private: const camera_module_callbacks_t *callbacks_; std::vector> cameras_; std::map cameraIdsMap_; - Mutex mutex_; + libcamera::Mutex mutex_; unsigned int numInternalCameras_; unsigned int nextExternalCameraId_; diff --git a/src/android/camera_request.h b/src/android/camera_request.h index f3cb6d64..88d501a8 100644 --- a/src/android/camera_request.h +++ b/src/android/camera_request.h @@ -9,10 +9,10 @@ #include #include -#include #include #include +#include #include #include @@ -58,7 +58,7 @@ public: /* Keeps track of streams requiring post-processing. */ std::map pendingStreamsToProcess_; - std::mutex streamsProcessMutex_; + libcamera::Mutex streamsProcessMutex_; Camera3RequestDescriptor(libcamera::Camera *camera, const camera3_capture_request_t *camera3Request); diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 9023c13c..5a62b7cd 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -119,7 +119,7 @@ int CameraStream::configure() if (type_ == Type::Internal) { allocator_ = std::make_unique(cameraDevice_->camera()); - mutex_ = std::make_unique(); + mutex_ = std::make_unique(); int ret = allocator_->allocate(stream()); if (ret < 0) @@ -208,7 +208,7 @@ FrameBuffer *CameraStream::getBuffer() if (!allocator_) return nullptr; - std::lock_guard locker(*mutex_); + MutexLocker locker(*mutex_); if (buffers_.empty()) { LOG(HAL, Error) << "Buffer underrun"; @@ -226,7 +226,7 @@ void CameraStream::putBuffer(FrameBuffer *buffer) if (!allocator_) return; - std::lock_guard locker(*mutex_); + MutexLocker locker(*mutex_); buffers_.push_back(buffer); } @@ -239,7 +239,7 @@ CameraStream::PostProcessorWorker::PostProcessorWorker(PostProcessor *postProces CameraStream::PostProcessorWorker::~PostProcessorWorker() { { - libcamera::MutexLocker lock(mutex_); + MutexLocker lock(mutex_); state_ = State::Stopped; } @@ -250,7 +250,7 @@ CameraStream::PostProcessorWorker::~PostProcessorWorker() void CameraStream::PostProcessorWorker::start() { { - libcamera::MutexLocker lock(mutex_); + MutexLocker lock(mutex_); ASSERT(state_ != State::Running); state_ = State::Running; } @@ -308,7 +308,7 @@ void CameraStream::PostProcessorWorker::run() void CameraStream::PostProcessorWorker::flush() { - libcamera::MutexLocker lock(mutex_); + MutexLocker lock(mutex_); state_ = State::Flushing; lock.unlock(); diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index e4808369..adb5a37d 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include @@ -173,7 +172,7 @@ private: * The class has to be MoveConstructible as instances are stored in * an std::vector in CameraDevice. */ - std::unique_ptr mutex_; + std::unique_ptr mutex_; std::unique_ptr postProcessor_; std::unique_ptr worker_;