From patchwork Mon Nov 29 11:44:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14844 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 A417DBF415 for ; Mon, 29 Nov 2021 11:45:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5A87D605A6; Mon, 29 Nov 2021 12:45:20 +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="fguIXqxk"; 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 6F66E605BC for ; Mon, 29 Nov 2021 12:45:15 +0100 (CET) Received: by mail-pl1-x630.google.com with SMTP id u17so11932293plg.9 for ; Mon, 29 Nov 2021 03:45:15 -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=jkEnNVnDsKxPXQVrOr2o6e7y66s+KmMxUJ0aP0RkLt0=; b=fguIXqxkiDO7csnL7NPKuBJWH+fC17FvaRhnDe9fpaavOAMs/+91UdwosGUUAoeT+F uxpu47OYoymbmp068czsfJZsh/kINlIYkz/DneryP4zc8ZZGoj2sT+6KCGP4mhWtuqc6 ovWa/OmEQfs55x5Z4NZOVpIyxpdcra03RwhxA= 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=jkEnNVnDsKxPXQVrOr2o6e7y66s+KmMxUJ0aP0RkLt0=; b=b2PAPDAS10+XSDezxitVX0zDIlulBqc0bsEUvVwM+iDhq6txQvbqeZEqiXwbOo0lDU VekFOKPWVejeSzkVRUoqXkYuyu8Jh8Kq8kSvdifwxSjUtWWaDPuFjF1v5js+MqmmJuSQ 8g8wswaryw5n+IMEf2/bNRtG8EkKJLUnBeoXPdjNZcgyJLxvikJ9hxKlRz67T0WpAJmK SICeIPRgTmfDMuChdHKdQyhMSKt0313KXDFQ5s0mtQbqcMtvQo1Qlq0TkZ2BEE+IST9w KBjrRFFd1t3mlB+UKpMuY3Ss+x0db6FQzwDj5bMgNw6D2Pej6S8FoIumu1YzsbuHla9g BjOw== X-Gm-Message-State: AOAM532Qw6RWiczGhkG72pdIxnyRnfbyweaiD6DC7sUQ/1E4UoY04oZK EwpHmgsAf8W5Ax9zgGrfY8noPswYqM7s3A== X-Google-Smtp-Source: ABdhPJzRDB1WHt8A9OoyiFDFs38E5DMFVEv6zg0QRDWnwGToROPWLIGEfA6IO/mS2MMlwBxBe95qCw== X-Received: by 2002:a17:903:408c:b0:142:45a9:672c with SMTP id z12-20020a170903408c00b0014245a9672cmr59279113plc.7.1638186313714; Mon, 29 Nov 2021 03:45:13 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:f254:cda9:46e8:17b7]) by smtp.gmail.com with ESMTPSA id hg4sm17951966pjb.1.2021.11.29.03.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 03:45:13 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Nov 2021 20:44:50 +0900 Message-Id: <20211129114453.3186042-9-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 Subject: [libcamera-devel] [PATCH v2 08/11] 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: Umang Jain Reviewed-by: Laurent Pinchart --- src/android/camera_stream.cpp | 2 +- src/android/camera_stream.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 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 c127a0e4..6737bd2d 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -8,13 +8,14 @@ #pragma once #include -#include #include #include #include +#include #include +#include #include #include @@ -155,8 +156,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 +171,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.