From patchwork Tue Nov 30 15:55:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14898 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 CE079BF415 for ; Tue, 30 Nov 2021 15:56:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7778B60725; Tue, 30 Nov 2021 16:56:13 +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="XFooAvm9"; dkim-atps=neutral Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82D6360710 for ; Tue, 30 Nov 2021 16:56:10 +0100 (CET) Received: by mail-pg1-x534.google.com with SMTP id s37so10567648pga.9 for ; Tue, 30 Nov 2021 07:56:10 -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=RfQVNtG/v2bEcPhs3B2DWL5RmPs7AC4Gxpfmf3NMFrs=; b=XFooAvm9HTjN2nuHjmizEWxIfAMJjX2h8N6mCH3eBjBFHuzE3b+dlJlB2L+hVNnzEt 5UXp/gznK6SuEUdLGwmOLalOa9ESmPTR7m5Epc7DYLPOMI07TOlA9fVgtWDjHj1InGsL eJ72cimj8DerLVaTjdB02nPRYcQYZdwP2iFGk= 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=RfQVNtG/v2bEcPhs3B2DWL5RmPs7AC4Gxpfmf3NMFrs=; b=qLy46waWRURDOBGvrnuWjvwlzQuv+tCrF8Ch7SIHX0USLarFIGgjw0Fm2w9pk5EXuc gvdlU/eZs2V26fXlVT1nWHuaD1eO4XKHW97s1GvLd/t+rgYmrEVdIK1XBN/VQRrrelqS Mz4uzGnvPQrWEFPTLFKgxVf5vk4Hh3ytiobzScLG2SGwD/hcCSWO94toDJXc899yHWbC Jk+3dc73ij53FCl4gGVRoi57Yo6ytbnB0OmiKWPxJK3zoV3xNW1AxKpzn1LyqbjZ9WAR TFu6tcOmM5rCCuwUQnKVAPcbd5A7+Ad0R+h/0lEOzQNQLA5II5+9uWjPcIz9gNCKG4tU /kng== X-Gm-Message-State: AOAM530HoviXO9gnRl/GghjN45cEqivQ4BhyxC3+RgRswpvoBFjusjKb GR0yU52eoM/vb/VdigjMF84AdpdMHrCgAA== X-Google-Smtp-Source: ABdhPJy9+UV1SFbz+7tD83/BGC5Odi/zN3luvchLAI5NHw9QwZoNvlJ95zp9VbBMvyTkY/KiFLO2ZQ== X-Received: by 2002:a63:5520:: with SMTP id j32mr39034899pgb.443.1638287768893; Tue, 30 Nov 2021 07:56:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 07:56:08 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 00:55:49 +0900 Message-Id: <20211130155600.2203123-2-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 01/12] libcamera: base: Introduce ConditionVariable 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" ConditionVariable is alias to std::condition_variable. This replaces std::condition_variable with the ConditionVariable. It enables replacing ConditionVariable implementation easily in the following patches. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- include/libcamera/base/semaphore.h | 4 +--- include/libcamera/base/thread.h | 2 ++ src/android/camera_stream.h | 3 +-- src/libcamera/base/thread.cpp | 8 ++++++-- src/libcamera/camera_manager.cpp | 3 +-- src/v4l2/v4l2_camera.h | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h index ae87d319..ec05fad3 100644 --- a/include/libcamera/base/semaphore.h +++ b/include/libcamera/base/semaphore.h @@ -7,8 +7,6 @@ #pragma once -#include - #include #include @@ -26,7 +24,7 @@ public: private: Mutex mutex_; - std::condition_variable cv_; + ConditionVariable cv_; unsigned int available_; }; diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h index 32ebc80a..1ebf8363 100644 --- a/include/libcamera/base/thread.h +++ b/include/libcamera/base/thread.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -26,6 +27,7 @@ class Object; class ThreadData; class ThreadMain; +using ConditionVariable = std::condition_variable; using Mutex = std::mutex; using MutexLocker = std::unique_lock; diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index e9da75f0..e4808369 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include #include @@ -154,7 +153,7 @@ private: PostProcessor *postProcessor_; libcamera::Mutex mutex_; - std::condition_variable cv_; + libcamera::ConditionVariable cv_; std::queue requests_; State state_ = State::Stopped; diff --git a/src/libcamera/base/thread.cpp b/src/libcamera/base/thread.cpp index d0ca30e3..b893135f 100644 --- a/src/libcamera/base/thread.cpp +++ b/src/libcamera/base/thread.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -158,7 +157,7 @@ private: std::atomic dispatcher_; - std::condition_variable cv_; + ConditionVariable cv_; std::atomic exit_; int exitCode_; @@ -205,6 +204,11 @@ ThreadData *ThreadData::current() return data; } +/** + * \typedef ConditionVariable + * \brief An alias for std::condition_variable + */ + /** * \typedef Mutex * \brief An alias for std::mutex diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index e78bb1d7..77ff3bd1 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -7,7 +7,6 @@ #include -#include #include #include @@ -63,7 +62,7 @@ private: void createPipelineHandlers(); void cleanup(); - std::condition_variable cv_; + ConditionVariable cv_; bool initialized_; int status_; diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index 94263b2f..4afbb331 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -82,6 +82,6 @@ private: int efd_; libcamera::Mutex bufferMutex_; - std::condition_variable bufferCV_; + libcamera::ConditionVariable bufferCV_; unsigned int bufferAvailableCount_; };