From patchwork Mon Nov 29 11:44:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14838 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 905BEC324F for ; Mon, 29 Nov 2021 11:45:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B8D46605B8; Mon, 29 Nov 2021 12:45:06 +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="HjGrtOh3"; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1351360597 for ; Mon, 29 Nov 2021 12:45:05 +0100 (CET) Received: by mail-pj1-x1030.google.com with SMTP id gf14-20020a17090ac7ce00b001a7a2a0b5c3so15346210pjb.5 for ; Mon, 29 Nov 2021 03:45:05 -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=CKY6AICRbf9hUVggpufuKtI4U9/jhpBFKpn2XVd4mAc=; b=HjGrtOh36vVlQ4LMb3lKh74pVRgQbi806JXorILKQauTBnHGgmgADdZrmNLlHFPeHw IZX9g/nakzyl4RLzSDNLv31O5oJDcq47ebtgyX+Vo9VbAG/4cOEJMse8w7+Ju0S6Mtrl gUvbc1DYkDGkDR4IkdMrAxRbo2K//iA384ErA= 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=CKY6AICRbf9hUVggpufuKtI4U9/jhpBFKpn2XVd4mAc=; b=jK/dxzAGUPmFKF/jVG37aFjjCFuueQ+5URxEO3WmjMfHctiAwQGFCS95N4Ma4BnCwA 79ntXpFc3yDVxBw/en/CSnfy0oJu3B5oD6uTeZ2eR6cNrBHk89IOqj+jsJjZBkDnXogK Zfk31Y3MwuBScTaGkAOkUDC9M5mb+D8mvwNTJZDUilYI0MSN2cecc4KNSpt5jpNr7kFK Iff2PtW1ggf77KxHQ4LrD+NReproD5xF+zVwzIoG5neq5DVzVTI+QstDoWa+TYBmrH0/ 1qmlbFmeoHSxLHu+B7S4U4rDOH1cISsompX3wUOU6bXUT1+QK7tkDKphXeQwQGTd0Qes ERHQ== X-Gm-Message-State: AOAM533FXmBs6Oyjf8xTlj52kRx11L22oYm9uZZ0ngklxdkdtstrJjom s1n8LLPOr/TDyxFPllIB29RNKCneyBmePQ== X-Google-Smtp-Source: ABdhPJyVyegGiFa5X1YbEe36XdUDCXXzaRnLhUNEGUn4czcXHThekskdpL/DQi4nGfv8yOuAl6SDkw== X-Received: by 2002:a17:90b:4c0d:: with SMTP id na13mr36578937pjb.206.1638186303377; Mon, 29 Nov 2021 03:45:03 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:f254:cda9:46e8:17b7]) by smtp.gmail.com with ESMTPSA id hg4sm17951966pjb.1.2021.11.29.03.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 03:45:03 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Nov 2021 20:44:44 +0900 Message-Id: <20211129114453.3186042-3-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211129114453.3186042-1-hiroh@chromium.org> References: <20211129114453.3186042-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/11] 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_hal_manager.h | 6 ++---- src/android/camera_request.h | 4 ++-- src/android/camera_stream.cpp | 12 ++++++------ src/android/camera_stream.h | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h index 192f2fc5..c07684a1 100644 --- a/src/android/camera_hal_manager.h +++ b/src/android/camera_hal_manager.h @@ -18,6 +18,7 @@ #include #include +#include #include @@ -44,9 +45,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 +62,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..c127a0e4 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -173,7 +173,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_;