From patchwork Wed Dec 1 07:53:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14942 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 D0C08BF415 for ; Wed, 1 Dec 2021 07:54:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82B4260718; Wed, 1 Dec 2021 08:54:01 +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="BvX48i06"; dkim-atps=neutral Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC51A60710 for ; Wed, 1 Dec 2021 08:53:59 +0100 (CET) Received: by mail-pj1-x1034.google.com with SMTP id gt5so17337192pjb.1 for ; Tue, 30 Nov 2021 23:53:59 -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=BvX48i06h4MxzzEwpkr2M6jb3Gb5DN2qJSTfniEIiP4OtbryLbNyHoc1DfrT1+nItO 0LG+hlhVUA7KxJ4iOSRi63CC6tvouPaEigmLXOHG0E/vevUllSMKQ8rcd991T2kQ2ory DKP182njMLwdbHLv+K8HtP1UW+kyeC6gAGCas= 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=zv0LP85qKXXI81yyaYtiQwE2FQXHyB+gx+r0pvu9aCb8KFFe4MX4dZWv7A/nyY5YfH mF7DPpb5qk03/ITcSmw0opnKbF92qPQxVHhzmSmFwJOmOkH/nKfN021ntMaPlFbmTEiR LbjHUANZfreDndcwrvDwPon9x11l+zMIWHDsDdlbjYn3Ln908FJBWW/ptqCvb7kkxibs f4lTF2e7QwHMvUvZMhloKbtBP3oRKo5KO6SUcZbXIcsrv7stPYXF07HNKrzmxEmQd5wd jAONQay1ek/l8ZFk/jtU2NkRcDj2NvIFbSl3W0EP26MD9ajdllrJlrPck7hKeYmOtgnB +bxQ== X-Gm-Message-State: AOAM530cI9ckcoTcjvRDlnWZ7aH56rex291YqT6Wx6HgEDomOtZAFdTi Eh1NG2y9T/xZn5VaVI2q3F4AKIeT2D6/KQ== X-Google-Smtp-Source: ABdhPJwXOGnGUkAQcGrVELBSEB2SXp3dzc1v+ibpGTdLHDGPaj+VXq8TAC8vQxEQ2+3iVpvwhf0EGA== X-Received: by 2002:a17:90a:db81:: with SMTP id h1mr5628120pjv.46.1638345237874; Tue, 30 Nov 2021 23:53:57 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id l9sm3500848pfu.55.2021.11.30.23.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:53:57 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:53:38 +0900 Message-Id: <20211201075348.3121186-3-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201075348.3121186-1-hiroh@chromium.org> References: <20211201075348.3121186-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 Reviewed-by: Umang Jain --- 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_;