From patchwork Wed Dec 1 07:53:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14951 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 6BAFCBF415 for ; Wed, 1 Dec 2021 07:54:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 21F6960727; Wed, 1 Dec 2021 08:54:17 +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="Ixaxy3Gu"; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 838AD60720 for ; Wed, 1 Dec 2021 08:54:15 +0100 (CET) Received: by mail-pj1-x1030.google.com with SMTP id cq22-20020a17090af99600b001a9550a17a5so20378892pjb.2 for ; Tue, 30 Nov 2021 23:54: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=t1EdNmb2krgv/F9K2Ewspd25zRV1hwTxg1Jn4yjsZWU=; b=Ixaxy3GuVLG803pXWFsSj724qX0bH9FhLluVkALfzhW9pbT0U4cams0KYhBsmn7Du6 vfRCRFLkNWozkHmze3CjNCrjGvBXTrQvIrcSXFufF6/xykwUgpd3h/jKIZrZFbYSkxqR RMqjh2sU2btC04rZd7MQbmcVWJMWlxlgH9HBA= 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=bicwEAYSA6R5UGbGr/Ke2QN8IeuKEQb/zk6hvmSll82s1JsREu0OSygLzjKiTD8e+f ub+nOBYNGu17zugrHkwka0cVfpk4neVr/XH4pQM6tjd8KE7y80f5d425zfHDMja8fBnu BNg1mD5jZX9JdotDnZqtPevO9jbWWBZ5f/imuHPSGKt5hdkE9dXh0abGOzt2YCIxFj7n ZCcJ1nSK/N+JrUKpgVmLuGIQVNRIQPrw6k9ufXkPvbpBgJoLLbplVpMVuwr8ldDA1mjH Avaij7eRdecriE7YV1V5jflQSA/8QeqGyf6eSeorHEzscNVRK4cYFhtN2tWwkVP3aNqX vGWQ== X-Gm-Message-State: AOAM532fOb6Qw1ogge5kTqQ9Jx/jw1U7tDyMAK33lZBtZ9MBD+d8e1aN kmtV0e7AHzokuB9Oy0eVX09770xAx2ziPg== X-Google-Smtp-Source: ABdhPJzSrtaVr5SrRdbdJrScoHOaCe/Aw6S5bombvA/O2/lVNTLIqYUSwHe5HsEtTE4agx7uRVKAnQ== X-Received: by 2002:a17:903:4053:b0:143:6d84:984c with SMTP id n19-20020a170903405300b001436d84984cmr5582218pla.37.1638345253909; Tue, 30 Nov 2021 23:54:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 23:54:13 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 16:53:47 +0900 Message-Id: <20211201075348.3121186-12-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 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 Reviewed-by: Umang Jain --- 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_;