{"id":14935,"url":"https://patchwork.libcamera.org/api/patches/14935/?format=json","web_url":"https://patchwork.libcamera.org/patch/14935/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211201070728.3114247-10-hiroh@chromium.org>","date":"2021-12-01T07:07:25","name":"[libcamera-devel,v4,09/12] android: camera_stream: Add thread safety annotation","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"420156a9f16230d719dcb50844d536b9601ac5bd","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14935/mbox/","series":[{"id":2789,"url":"https://patchwork.libcamera.org/api/series/2789/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2789","date":"2021-12-01T07:07:16","name":"Introduce clang thread safety annotations","version":4,"mbox":"https://patchwork.libcamera.org/series/2789/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14935/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14935/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 64E67BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Dec 2021 07:07:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 241C560727;\n\tWed,  1 Dec 2021 08:07:54 +0100 (CET)","from mail-pl1-x630.google.com (mail-pl1-x630.google.com\n\t[IPv6:2607:f8b0:4864:20::630])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 253096072B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Dec 2021 08:07:52 +0100 (CET)","by mail-pl1-x630.google.com with SMTP id p18so16926592plf.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 23:07:52 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:3892:a049:59ba:c772])\n\tby smtp.gmail.com with ESMTPSA id\n\tm10sm16598962pgv.75.2021.11.30.23.07.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 23:07:49 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"mthpzqzP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=AQIBNqacdqTMVVj1+/N7sLikHJdd0HfW4RrtBwMeJFk=;\n\tb=mthpzqzPHyAwhR37Zbphnf0hXhOcL9HHVoNUj8FM29OvTRmpGxP/F5F2luO3FA8m7z\n\tDoM08Uo7txGV2qV8dhE2GohFPtup9ZbYjbxv6/Ti8Rtq0AgFoDeG2M2fnA3i5G9e9J+J\n\tipuUbPVAtGqxy37PARZv/TB9dA6FI5lPfJTok=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=AQIBNqacdqTMVVj1+/N7sLikHJdd0HfW4RrtBwMeJFk=;\n\tb=KYzQuoc6Rre5WXRGlpwE+YkEW9VNfUcRkuqUuM18az2bHnmjrvpiKUqXbenzLt0he6\n\t57AJL4VJUHrMOWRskr8263vikq4SOvr1mTlePazDvPQh4N0azMUbJve/suLCW7rfQqca\n\t338PdL3b/jrOlx2K1OMkR7mTmrsd62Al4Saw7LzqO2raoRPL1jNmPyWdmdVZ6/EDqEYM\n\tpg6iG6danU6xtCG+AF4S5KBU+sMAr6DqdYj4MfALMwQ7IY5pTEO8rNj9XQDrPUYMq111\n\tQbuUc9a3ITzxnDopBO27mmOaB6vPwv+i5GGOGBpLYiu5Yj+kTcgiRrmjQzBoCd0zXGF+\n\tS/eQ==","X-Gm-Message-State":"AOAM533Pr3iIt13jOPyohCqXTEFau9ZxmJZzjCoBOQ7tnc+geq+NYepv\n\twDsSWDoCKiWknDrzUsL70PEhnlwQfoJzEg==","X-Google-Smtp-Source":"ABdhPJxF+9+F0MIBhfToCAo9Pvku8gnqP56wcsOhHINrekNanXKMggJ353by+qWsrf3q6wcCHeMOOg==","X-Received":"by 2002:a17:90b:4c44:: with SMTP id\n\tnp4mr5233285pjb.195.1638342470477; \n\tTue, 30 Nov 2021 23:07:50 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 09/12] android: camera_stream: Add\n\tthread safety annotation","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This applies clang thread safety annotation to CameraStream.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/android/camera_stream.cpp | 2 +-\n src/android/camera_stream.h   | 8 +++++---\n 2 files changed, 6 insertions(+), 4 deletions(-)","diff":"diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 2181d094..ae659808 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -275,7 +275,7 @@ void CameraStream::PostProcessorWorker::run()\n \tMutexLocker locker(mutex_);\n \n \twhile (1) {\n-\t\tcv_.wait(locker, [&] {\n+\t\tcv_.wait(locker, [&]() LIBCAMERA_TSA_REQUIRES(mutex_) {\n \t\t\treturn state_ != State::Running || !requests_.empty();\n \t\t});\n \ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex e4eb953a..7b1a2980 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -155,8 +155,10 @@ private:\n \t\tlibcamera::Mutex mutex_;\n \t\tlibcamera::ConditionVariable cv_;\n \n-\t\tstd::queue<Camera3RequestDescriptor::StreamBuffer *> requests_;\n-\t\tState state_ = State::Stopped;\n+\t\tstd::queue<Camera3RequestDescriptor::StreamBuffer *> requests_\n+\t\t\tLIBCAMERA_TSA_GUARDED_BY(mutex_);\n+\n+\t\tState state_ LIBCAMERA_TSA_GUARDED_BY(mutex_) = State::Stopped;\n \t};\n \n \tint waitFence(int fence);\n@@ -168,7 +170,7 @@ private:\n \tconst unsigned int index_;\n \n \tstd::unique_ptr<libcamera::FrameBufferAllocator> allocator_;\n-\tstd::vector<libcamera::FrameBuffer *> buffers_;\n+\tstd::vector<libcamera::FrameBuffer *> buffers_ LIBCAMERA_TSA_GUARDED_BY(mutex_);\n \t/*\n \t * The class has to be MoveConstructible as instances are stored in\n \t * an std::vector in CameraDevice.\n","prefixes":["libcamera-devel","v4","09/12"]}