From patchwork Wed Dec 1 07:07:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14935 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 64E67BDB13 for ; Wed, 1 Dec 2021 07:07:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 241C560727; Wed, 1 Dec 2021 08:07:54 +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="mthpzqzP"; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 253096072B for ; Wed, 1 Dec 2021 08:07:52 +0100 (CET) Received: by mail-pl1-x630.google.com with SMTP id p18so16926592plf.13 for ; Tue, 30 Nov 2021 23:07:52 -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=mthpzqzPHyAwhR37Zbphnf0hXhOcL9HHVoNUj8FM29OvTRmpGxP/F5F2luO3FA8m7z DoM08Uo7txGV2qV8dhE2GohFPtup9ZbYjbxv6/Ti8Rtq0AgFoDeG2M2fnA3i5G9e9J+J ipuUbPVAtGqxy37PARZv/TB9dA6FI5lPfJTok= 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=KYzQuoc6Rre5WXRGlpwE+YkEW9VNfUcRkuqUuM18az2bHnmjrvpiKUqXbenzLt0he6 57AJL4VJUHrMOWRskr8263vikq4SOvr1mTlePazDvPQh4N0azMUbJve/suLCW7rfQqca 338PdL3b/jrOlx2K1OMkR7mTmrsd62Al4Saw7LzqO2raoRPL1jNmPyWdmdVZ6/EDqEYM pg6iG6danU6xtCG+AF4S5KBU+sMAr6DqdYj4MfALMwQ7IY5pTEO8rNj9XQDrPUYMq111 QbuUc9a3ITzxnDopBO27mmOaB6vPwv+i5GGOGBpLYiu5Yj+kTcgiRrmjQzBoCd0zXGF+ S/eQ== X-Gm-Message-State: AOAM533Pr3iIt13jOPyohCqXTEFau9ZxmJZzjCoBOQ7tnc+geq+NYepv wDsSWDoCKiWknDrzUsL70PEhnlwQfoJzEg== X-Google-Smtp-Source: ABdhPJxF+9+F0MIBhfToCAo9Pvku8gnqP56wcsOhHINrekNanXKMggJ353by+qWsrf3q6wcCHeMOOg== X-Received: by 2002:a17:90b:4c44:: with SMTP id np4mr5233285pjb.195.1638342470477; Tue, 30 Nov 2021 23:07:50 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:3892:a049:59ba:c772]) by smtp.gmail.com with ESMTPSA id m10sm16598962pgv.75.2021.11.30.23.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:07:49 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:07:25 +0900 Message-Id: <20211201070728.3114247-10-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211201070728.3114247-1-hiroh@chromium.org> References: <20211201070728.3114247-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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.