From patchwork Tue Nov 30 15:55:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14899 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 437BBBF415 for ; Tue, 30 Nov 2021 15:56:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 41D0660729; Tue, 30 Nov 2021 16:56:14 +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="RCBnXTOT"; dkim-atps=neutral Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 63040605C4 for ; Tue, 30 Nov 2021 16:56:12 +0100 (CET) Received: by mail-pg1-x535.google.com with SMTP id r5so20189937pgi.6 for ; Tue, 30 Nov 2021 07:56:12 -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=RCBnXTOTviLcSK2W20Eo6ALjoCqLDIH4sBqnbEyQC3f49H8OkCwgCDmDnBleBwKW6S uJVp3dlyUfEsubbxq19hQuisJQ/abev2hPuXTe7KxVOTWGYF2Wm4SGHpIUhHi8gKRj38 p6wcLDd7RL+QXlfdboXpSLiAFNELJbs6OzOZ8= 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=4WaYBD4obeLdxh7ziL643IgPWydj67msBoubRxzE5ZcpM5xvZUDORX5LU4lL/AlGvt XWk//6Omhz05PRw0Cm1AsL4YZaIVGk283GWypGlQ+zjTu63bR10Dz8864uodxJo7Lk90 Np+QnHicEg1X1JuIFGfqRyEnhuhyRwFNEmOTKemaC49xJ37GMkvE4LQyqSOf99HTIA7b EncbQvNeKzyZQYahNNipb/f37oF7eWoZqk5o8mXZor0C8Pw12FFsj90nv29FrbibGKFM A8j1JlSL3og9IlEWoxYsbyfN3XjKtDh+3KTidk23x9uWzJl78EIf0tRczVxFnatCM8Q2 gNrw== X-Gm-Message-State: AOAM533yeo615Q12Bxy/yLHvdaq4fovOMTkUHAks507EZIhncYWDK6dP 6Sv2OWyp32JoLXkVgc/Y1dR6M/B3IvXOwQ== X-Google-Smtp-Source: ABdhPJwSP6zwtlzePuscHfYFTbBQN7SfTxsDOq3gAMDLqxeds4KpTKLOzCkRWh7jATp+FOuKAxwHTw== X-Received: by 2002:a05:6a00:b89:b0:49f:f600:658f with SMTP id g9-20020a056a000b8900b0049ff600658fmr47648644pfj.71.1638287770696; Tue, 30 Nov 2021 07:56:10 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:c90a:5a53:b139:1336]) by smtp.gmail.com with ESMTPSA id pc10sm3510283pjb.9.2021.11.30.07.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 07:56:10 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 00:55:50 +0900 Message-Id: <20211130155600.2203123-3-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211130155600.2203123-1-hiroh@chromium.org> References: <20211130155600.2203123-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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_;