From patchwork Wed Dec 1 07:07:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14937 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 3F91CBDB13 for ; Wed, 1 Dec 2021 07:07:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E98B86072E; Wed, 1 Dec 2021 08:07:57 +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="iKaG2p6K"; dkim-atps=neutral Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ADE5660718 for ; Wed, 1 Dec 2021 08:07:55 +0100 (CET) Received: by mail-pf1-x436.google.com with SMTP id b68so23406980pfg.11 for ; Tue, 30 Nov 2021 23:07:55 -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=t1EdNmb2krgv/F9K2Ewspd25zRV1hwTxg1Jn4yjsZWU=; b=iKaG2p6KR6qwcJz68fTFOUccDIxNwBSEgBc7rupt1WO5I10C/cxvZqp/JMwcQq6pVU wFl6/pX+TJPOi9E1RZX1P6kVt4/pXTBam/ppGekWZ37NphvPV0Yq1Jzl0wY5BzEFJT41 A0XmGA3uI7cSQ3Tgl0wZdlvTDV9gwo/yRQ+x4= 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=t1EdNmb2krgv/F9K2Ewspd25zRV1hwTxg1Jn4yjsZWU=; b=Vj8wFBfgRM2gPZeXDBI00kO87CNZ0yXR7YwJqPVNuJIOwxjjnw1or/RLei8bQIA0BS NL8ja2JM145lCAzbqJrOoq8tY5N80cnAn9HoG8BkqUERIRkM4KP5lcPqzaQ4HEzkxL1x X6GBGN+ZCnPIHV7jGr0XblH73PXGgotxW1vRKy+YjJxxtXWaB3sbelYXXBmZvjd5gQyN ofcIWXhJxlQuSNdUgyE4b6HcODiFlB2gcLlu4p8A8KLhOtVxNmDkvVnxa+qHf5yEeBgo ahnGoZt0MRfy9HUJ8sVa6zvwg2zwQ9BBVLYXPYS36SVDdiZdRauw1snEfA0pg8wSmdoe T0tQ== X-Gm-Message-State: AOAM531tX0N7fFla+1fAr3D5g1MdNssY1/iOI+pk0dYgQJJoEL7RuETG X8xSxiMlrxEhDaS4m0fJcQP7srmdXv3qEw== X-Google-Smtp-Source: ABdhPJzUsfihOASXc76xlhPYU4nYFFmaIQTqXcKBVpXCOn+G/1Kg1hcmhTEUWyozSaNofKNT5QzoAA== X-Received: by 2002:aa7:9e9c:0:b0:49f:c7cf:ff5 with SMTP id p28-20020aa79e9c000000b0049fc7cf0ff5mr4144964pfq.62.1638342474034; Tue, 30 Nov 2021 23:07:54 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:07:53 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:07:27 +0900 Message-Id: <20211201070728.3114247-12-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 11/12] android: camera_device: 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 CameraDevice. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/android/camera_device.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.h b/src/android/camera_device.h index a945f5de..e5d9cda2 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -82,7 +82,7 @@ private: Running, }; - void stop(); + void stop() LIBCAMERA_TSA_EXCLUDES(stateMutex_); std::unique_ptr createFrameBuffer(const buffer_handle_t camera3buffer, @@ -94,8 +94,9 @@ private: void notifyError(uint32_t frameNumber, camera3_stream_t *stream, camera3_error_msg_code code) const; int processControls(Camera3RequestDescriptor *descriptor); - void completeDescriptor(Camera3RequestDescriptor *descriptor); - void sendCaptureResults(); + void completeDescriptor(Camera3RequestDescriptor *descriptor) + LIBCAMERA_TSA_EXCLUDES(descriptorsMutex_); + void sendCaptureResults() LIBCAMERA_TSA_REQUIRES(descriptorsMutex_); void setBufferStatus(Camera3RequestDescriptor::StreamBuffer &buffer, Camera3RequestDescriptor::Status status); std::unique_ptr getResultMetadata( @@ -107,7 +108,7 @@ private: CameraWorker worker_; libcamera::Mutex stateMutex_; /* Protects access to the camera state. */ - State state_; + State state_ LIBCAMERA_TSA_GUARDED_BY(stateMutex_); std::shared_ptr camera_; std::unique_ptr config_; @@ -118,8 +119,9 @@ private: std::vector streams_; - libcamera::Mutex descriptorsMutex_; /* Protects descriptors_. */ - std::queue> descriptors_; + libcamera::Mutex descriptorsMutex_ LIBCAMERA_TSA_ACQUIRED_AFTER(stateMutex_); + std::queue> descriptors_ + LIBCAMERA_TSA_GUARDED_BY(descriptorsMutex_); std::string maker_; std::string model_;