From patchwork Wed Dec 1 07:53:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14949 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 A8BD5BF415 for ; Wed, 1 Dec 2021 07:54:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 23F2460710; Wed, 1 Dec 2021 08:54: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="PPJwu3K4"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1410F60727 for ; Wed, 1 Dec 2021 08:54:12 +0100 (CET) Received: by mail-pl1-x636.google.com with SMTP id o14so17040167plg.5 for ; Tue, 30 Nov 2021 23:54:12 -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=AQIBNqacdqTMVVj1+/N7sLikHJdd0HfW4RrtBwMeJFk=; b=PPJwu3K4h7g4wpWqG1pLHsM45BREkw+UL8ixhzcQ0BJP1vU2DU+sS0aMsPo6mb23S+ fngmPI9+YpB77xf6xfsRqXNb7YeyJtCd/9gieX7+WwtUjFp63GM19JhsCxC8WWtxxYfZ /zol5Q66ubyfBk10PPjhzb4VfZ7uZF1QrCozs= 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=AQIBNqacdqTMVVj1+/N7sLikHJdd0HfW4RrtBwMeJFk=; b=vQm92Ie92ATbMgj26B4Kf817I/GdAIa2orGQZg6zz4DpueybI0AOfAMz7TkCPBqj34 bMpWs1Y84ch8AUkB1aO/pGMJ7q4uT3p0NvULmyREowAT2f0xEyqS9RhpyA4lYufBHxgl QbNl3M1JNQYvff3Ey9/zKXyfZ3yvmF27R0v+I/pnZbsROnnK6n7y2K1k3nf+sie8FPHQ mncEWyNfObQxVWYjmWy1RPpQ4egezgJkHpkGhJ+Li9d2pi7cwNBuwSFKIiRr4DLTJ8CR 61IVR/50gfuauJ1s4tojIyTuRh7yl4WOIaQ74z7vxW/9G7KFObstoyJEZZzpw3kbfPiH OCJg== X-Gm-Message-State: AOAM533BDBAoHZDeEIjirxBpu74n8kznPxZjHbkj/x2sQJVlT9PZdN6F hOELFnC6xwC0PmcSdnb9gAdSVHJXdJCIZA== X-Google-Smtp-Source: ABdhPJwOyThNx/xsjT9+3BnoZ1q1tPITOyu1FpmqpzPg2pm9BvntNH2jX4e4c5g3SvXE5gE+fZy5gg== X-Received: by 2002:a17:902:e84e:b0:141:e3f2:36c5 with SMTP id t14-20020a170902e84e00b00141e3f236c5mr5582248plg.74.1638345250392; Tue, 30 Nov 2021 23:54:10 -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.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:54:10 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:53:45 +0900 Message-Id: <20211201075348.3121186-10-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 09/12] android: camera_stream: Add thread safety annotation 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" This applies clang thread safety annotation to CameraStream. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/android/camera_stream.cpp | 2 +- src/android/camera_stream.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 2181d094..ae659808 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -275,7 +275,7 @@ void CameraStream::PostProcessorWorker::run() MutexLocker locker(mutex_); while (1) { - cv_.wait(locker, [&] { + cv_.wait(locker, [&]() LIBCAMERA_TSA_REQUIRES(mutex_) { return state_ != State::Running || !requests_.empty(); }); diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index e4eb953a..7b1a2980 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -155,8 +155,10 @@ private: libcamera::Mutex mutex_; libcamera::ConditionVariable cv_; - std::queue requests_; - State state_ = State::Stopped; + std::queue requests_ + LIBCAMERA_TSA_GUARDED_BY(mutex_); + + State state_ LIBCAMERA_TSA_GUARDED_BY(mutex_) = State::Stopped; }; int waitFence(int fence); @@ -168,7 +170,7 @@ private: const unsigned int index_; std::unique_ptr allocator_; - std::vector buffers_; + std::vector buffers_ LIBCAMERA_TSA_GUARDED_BY(mutex_); /* * The class has to be MoveConstructible as instances are stored in * an std::vector in CameraDevice.