{"id":14838,"url":"https://patchwork.libcamera.org/api/1.1/patches/14838/?format=json","web_url":"https://patchwork.libcamera.org/patch/14838/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211129114453.3186042-3-hiroh@chromium.org>","date":"2021-11-29T11:44:44","name":"[libcamera-devel,v2,02/11] android: Consolidate mutex classes to Mutex and MutexLocker","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"501d3cfef69e62169cc05eae1612837edd478a25","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14838/mbox/","series":[{"id":2770,"url":"https://patchwork.libcamera.org/api/1.1/series/2770/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2770","date":"2021-11-29T11:44:42","name":"Introduce clang thread safety annotations","version":2,"mbox":"https://patchwork.libcamera.org/series/2770/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14838/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14838/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 905BEC324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Nov 2021 11:45:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B8D46605B8;\n\tMon, 29 Nov 2021 12:45:06 +0100 (CET)","from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com\n\t[IPv6:2607:f8b0:4864:20::1030])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1351360597\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 12:45:05 +0100 (CET)","by mail-pj1-x1030.google.com with SMTP id\n\tgf14-20020a17090ac7ce00b001a7a2a0b5c3so15346210pjb.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Nov 2021 03:45:05 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:f254:cda9:46e8:17b7])\n\tby smtp.gmail.com with ESMTPSA id\n\thg4sm17951966pjb.1.2021.11.29.03.45.02\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 29 Nov 2021 03:45:03 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"HjGrtOh3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=CKY6AICRbf9hUVggpufuKtI4U9/jhpBFKpn2XVd4mAc=;\n\tb=HjGrtOh36vVlQ4LMb3lKh74pVRgQbi806JXorILKQauTBnHGgmgADdZrmNLlHFPeHw\n\tIZX9g/nakzyl4RLzSDNLv31O5oJDcq47ebtgyX+Vo9VbAG/4cOEJMse8w7+Ju0S6Mtrl\n\tgUvbc1DYkDGkDR4IkdMrAxRbo2K//iA384ErA=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=CKY6AICRbf9hUVggpufuKtI4U9/jhpBFKpn2XVd4mAc=;\n\tb=jK/dxzAGUPmFKF/jVG37aFjjCFuueQ+5URxEO3WmjMfHctiAwQGFCS95N4Ma4BnCwA\n\t79ntXpFc3yDVxBw/en/CSnfy0oJu3B5oD6uTeZ2eR6cNrBHk89IOqj+jsJjZBkDnXogK\n\tZfk31Y3MwuBScTaGkAOkUDC9M5mb+D8mvwNTJZDUilYI0MSN2cecc4KNSpt5jpNr7kFK\n\tIff2PtW1ggf77KxHQ4LrD+NReproD5xF+zVwzIoG5neq5DVzVTI+QstDoWa+TYBmrH0/\n\t1qmlbFmeoHSxLHu+B7S4U4rDOH1cISsompX3wUOU6bXUT1+QK7tkDKphXeQwQGTd0Qes\n\tERHQ==","X-Gm-Message-State":"AOAM533FXmBs6Oyjf8xTlj52kRx11L22oYm9uZZ0ngklxdkdtstrJjom\n\ts1n8LLPOr/TDyxFPllIB29RNKCneyBmePQ==","X-Google-Smtp-Source":"ABdhPJyVyegGiFa5X1YbEe36XdUDCXXzaRnLhUNEGUn4czcXHThekskdpL/DQi4nGfv8yOuAl6SDkw==","X-Received":"by 2002:a17:90b:4c0d:: with SMTP id\n\tna13mr36578937pjb.206.1638186303377; \n\tMon, 29 Nov 2021 03:45:03 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 02/11] android: Consolidate mutex\n\tclasses to Mutex and MutexLocker","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"std::mutex and std::unique_lcok are used in android directories,\nmixing Mutex and MutexLocker. This consolidates them to Mutex\nand MutexLocker.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_hal_manager.h |  6 ++----\n src/android/camera_request.h     |  4 ++--\n src/android/camera_stream.cpp    | 12 ++++++------\n src/android/camera_stream.h      |  2 +-\n 4 files changed, 11 insertions(+), 13 deletions(-)","diff":"diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\nindex 192f2fc5..c07684a1 100644\n--- a/src/android/camera_hal_manager.h\n+++ b/src/android/camera_hal_manager.h\n@@ -18,6 +18,7 @@\n #include <system/camera_metadata.h>\n \n #include <libcamera/base/class.h>\n+#include <libcamera/base/thread.h>\n \n #include <libcamera/camera_manager.h>\n \n@@ -44,9 +45,6 @@ public:\n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(CameraHalManager)\n \n-\tusing Mutex = std::mutex;\n-\tusing MutexLocker = std::unique_lock<std::mutex>;\n-\n \tstatic constexpr unsigned int firstExternalCameraId_ = 1000;\n \n \tCameraHalManager();\n@@ -64,7 +62,7 @@ private:\n \tconst camera_module_callbacks_t *callbacks_;\n \tstd::vector<std::unique_ptr<CameraDevice>> cameras_;\n \tstd::map<std::string, unsigned int> cameraIdsMap_;\n-\tMutex mutex_;\n+\tlibcamera::Mutex mutex_;\n \n \tunsigned int numInternalCameras_;\n \tunsigned int nextExternalCameraId_;\ndiff --git a/src/android/camera_request.h b/src/android/camera_request.h\nindex f3cb6d64..88d501a8 100644\n--- a/src/android/camera_request.h\n+++ b/src/android/camera_request.h\n@@ -9,10 +9,10 @@\n \n #include <map>\n #include <memory>\n-#include <mutex>\n #include <vector>\n \n #include <libcamera/base/class.h>\n+#include <libcamera/base/thread.h>\n \n #include <libcamera/camera.h>\n #include <libcamera/framebuffer.h>\n@@ -58,7 +58,7 @@ public:\n \n \t/* Keeps track of streams requiring post-processing. */\n \tstd::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;\n-\tstd::mutex streamsProcessMutex_;\n+\tlibcamera::Mutex streamsProcessMutex_;\n \n \tCamera3RequestDescriptor(libcamera::Camera *camera,\n \t\t\t\t const camera3_capture_request_t *camera3Request);\ndiff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 9023c13c..5a62b7cd 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -119,7 +119,7 @@ int CameraStream::configure()\n \n \tif (type_ == Type::Internal) {\n \t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n-\t\tmutex_ = std::make_unique<std::mutex>();\n+\t\tmutex_ = std::make_unique<Mutex>();\n \n \t\tint ret = allocator_->allocate(stream());\n \t\tif (ret < 0)\n@@ -208,7 +208,7 @@ FrameBuffer *CameraStream::getBuffer()\n \tif (!allocator_)\n \t\treturn nullptr;\n \n-\tstd::lock_guard<std::mutex> locker(*mutex_);\n+\tMutexLocker locker(*mutex_);\n \n \tif (buffers_.empty()) {\n \t\tLOG(HAL, Error) << \"Buffer underrun\";\n@@ -226,7 +226,7 @@ void CameraStream::putBuffer(FrameBuffer *buffer)\n \tif (!allocator_)\n \t\treturn;\n \n-\tstd::lock_guard<std::mutex> locker(*mutex_);\n+\tMutexLocker locker(*mutex_);\n \n \tbuffers_.push_back(buffer);\n }\n@@ -239,7 +239,7 @@ CameraStream::PostProcessorWorker::PostProcessorWorker(PostProcessor *postProces\n CameraStream::PostProcessorWorker::~PostProcessorWorker()\n {\n \t{\n-\t\tlibcamera::MutexLocker lock(mutex_);\n+\t\tMutexLocker lock(mutex_);\n \t\tstate_ = State::Stopped;\n \t}\n \n@@ -250,7 +250,7 @@ CameraStream::PostProcessorWorker::~PostProcessorWorker()\n void CameraStream::PostProcessorWorker::start()\n {\n \t{\n-\t\tlibcamera::MutexLocker lock(mutex_);\n+\t\tMutexLocker lock(mutex_);\n \t\tASSERT(state_ != State::Running);\n \t\tstate_ = State::Running;\n \t}\n@@ -308,7 +308,7 @@ void CameraStream::PostProcessorWorker::run()\n \n void CameraStream::PostProcessorWorker::flush()\n {\n-\tlibcamera::MutexLocker lock(mutex_);\n+\tMutexLocker lock(mutex_);\n \tstate_ = State::Flushing;\n \tlock.unlock();\n \ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex e4808369..c127a0e4 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -173,7 +173,7 @@ private:\n \t * The class has to be MoveConstructible as instances are stored in\n \t * an std::vector in CameraDevice.\n \t */\n-\tstd::unique_ptr<std::mutex> mutex_;\n+\tstd::unique_ptr<libcamera::Mutex> mutex_;\n \tstd::unique_ptr<PostProcessor> postProcessor_;\n \n \tstd::unique_ptr<PostProcessorWorker> worker_;\n","prefixes":["libcamera-devel","v2","02/11"]}