From patchwork Tue Nov 30 15:55:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14908 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 807FFBF415 for ; Tue, 30 Nov 2021 15:56:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1B83260721; Tue, 30 Nov 2021 16:56:32 +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="Wj7dn/VB"; dkim-atps=neutral Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0B61560723 for ; Tue, 30 Nov 2021 16:56:29 +0100 (CET) Received: by mail-pl1-x634.google.com with SMTP id p18so15242885plf.13 for ; Tue, 30 Nov 2021 07:56:28 -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=eSIHoo+cZo+7Eu+mUseGv7nouggocX5mQcNX6VZPt/o=; b=Wj7dn/VBoCkyK3OdSafLMwafDC4WgV8+iw1QWl08AuXtVZvjumsYNsrJxN1IoTrLm/ y3BHLjlswxroyQstVczyCwJre6G49EQacDa7hv6Ayh7gnk2gzS7D6eVeT9zMVxi8nMs/ P/frg9PPUo/5c9FsSzuZZGk7dG/4vlEd09n/s= 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=eSIHoo+cZo+7Eu+mUseGv7nouggocX5mQcNX6VZPt/o=; b=KaOG1u4GqKvIVlYjuZ80MW/86tbt+LoqNPcd5OIatmLdV2Hi936WZJmvnbY1u1XOt8 OPTT9FHshDEtkCIT5TDiR3503Pb4eNe3y8RIq3tcD9hRUdwZQdbHQqKxNnumdgbc5ts/ BD9CBux19oB253KD5sn/GNDT5juuLj6pY4VGBhoTkUDxrjXNs10U8Q2hAk37O39Sz+iT Bo1oI3Xvh6sNb4e9v96ttq6qHRtrVJUFtFU7Lq+pN+iEPrbjLCOV0+yXpRf9+17VnydZ Od7yuwVOjl6RGpmQz+Gk5sTIjIoRFn6xEszbYT7mNRGGaAuNewTm1NbWdivu0kAK4V8/ HagA== X-Gm-Message-State: AOAM531XL04rFbWrTZbDzDqYDN0YLs5492XOpDThPrYkogEhgyxmlyA0 rEoOi4eBJsGXU3kf9idlm2XUmeW01B3tcA== X-Google-Smtp-Source: ABdhPJxNogVXR9khvBK4dPKzDiC3vv63LZ92qyVpSVYnE0mO7T9fZmea5mGGUUES3hSa0RI+3fZqRQ== X-Received: by 2002:a17:90b:164c:: with SMTP id il12mr241908pjb.241.1638287787387; Tue, 30 Nov 2021 07:56:27 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:c90a:5a53:b139:1336]) by smtp.gmail.com with ESMTPSA id pc10sm3510283pjb.9.2021.11.30.07.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Nov 2021 07:56:26 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 1 Dec 2021 00:55:59 +0900 Message-Id: <20211130155600.2203123-12-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211130155600.2203123-1-hiroh@chromium.org> References: <20211130155600.2203123-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.h b/src/android/camera_device.h index a945f5de..2083dac1 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -82,7 +83,7 @@ private: Running, }; - void stop(); + void stop() LIBCAMERA_TSA_EXCLUDES(stateMutex_); std::unique_ptr createFrameBuffer(const buffer_handle_t camera3buffer, @@ -94,8 +95,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 +109,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 +120,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_;