From patchwork Wed Dec 1 07:53:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14941 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 604EFBF415 for ; Wed, 1 Dec 2021 07:53:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E6F460718; Wed, 1 Dec 2021 08:53:59 +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="JyjcwSYz"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C286460723 for ; Wed, 1 Dec 2021 08:53:57 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id n85so23507344pfd.10 for ; Tue, 30 Nov 2021 23:53:57 -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=JyjcwSYzD38HqNjvbFMNMYF3FaDfjicow+so1nvqGCqSNfvVsB6G9oSaDWMjvtut6T yzRtSVAfHpywukN66RIyvjtMfXu0gR0tDeEPCmmwxM8NZ1BCdNrNS9ZLtYhmAbQhcbzN xFS6Q7jx/h94Hk9knxNlEThpiZIDMbsdd3e4s= 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=qsZVBbhulFiTpMsleidF0I9wEinD0fzkIb58uZFA6nSO5OABrbxfCVvJUGnxw5iEie j2eQ42AVwQYybMDyK2CvWoVGD/sd+mu2UcFztoWXVOL2x3ec1rdQE1Yl0L4ubINNuM3B BUveAxLtN/IvV4yO0aig2Te0I7PnpEf5lL/jooe62rNv1lOp9sTi+b+jWsl2kLDHBj51 M3gaRhlmpf8Bz+JTzJvJb8l2JolowMv1yNfaNOIZv6M5WQ3fIYnJwpTUwbQJgwwXHK6y EKcIH1qgi0g4B7jPqiXm+1bfRhJOzVCOAcSSCP3o8ypixIIV8oAluGr6fiqIq2boACH5 F+MQ== X-Gm-Message-State: AOAM533+XaY3Y4/qAZE0/8pf4xhRxzt2FaXmrlSPWTAk/tqDq5KNbVdF iTPqxLQ2UTYkWj/HPqX1qx0ZDKqIlN7ZOA== X-Google-Smtp-Source: ABdhPJy3+fLDXV/ZbUeibs52I82ZGI5yb1Im2YGtqghxbWE5eWDSvGVQBduLApxUut9gmikNJWP/6g== X-Received: by 2002:aa7:804b:0:b0:4a4:b2e2:e046 with SMTP id y11-20020aa7804b000000b004a4b2e2e046mr4492014pfm.81.1638345236158; Tue, 30 Nov 2021 23:53:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:53:55 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:53:37 +0900 Message-Id: <20211201075348.3121186-2-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 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 Reviewed-by: Umang Jain --- 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_; };