[libcamera-devel,v3,07/12] android: camera_hal_manager: Add thread safety annotation
diff mbox series

Message ID 20211130155600.2203123-8-hiroh@chromium.org
State Superseded
Headers show
Series
  • Introduce clang thread safety annotations
Related show

Commit Message

Hirokazu Honda Nov. 30, 2021, 3:55 p.m. UTC
This applies clang thread safety annotation to CameraHalManager.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/android/camera_hal_manager.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h
index 765701b2..5395d419 100644
--- a/src/android/camera_hal_manager.h
+++ b/src/android/camera_hal_manager.h
@@ -18,6 +18,7 @@ 
 
 #include <libcamera/base/class.h>
 #include <libcamera/base/mutex.h>
+#include <libcamera/base/thread_annotations.h>
 
 #include <libcamera/camera_manager.h>
 
@@ -53,14 +54,14 @@  private:
 	void cameraAdded(std::shared_ptr<libcamera::Camera> cam);
 	void cameraRemoved(std::shared_ptr<libcamera::Camera> cam);
 
-	CameraDevice *cameraDeviceFromHalId(unsigned int id);
+	CameraDevice *cameraDeviceFromHalId(unsigned int id) LIBCAMERA_TSA_REQUIRES(mutex_);
 
 	std::unique_ptr<libcamera::CameraManager> cameraManager_;
 	CameraHalConfig halConfig_;
 
 	const camera_module_callbacks_t *callbacks_;
-	std::vector<std::unique_ptr<CameraDevice>> cameras_;
-	std::map<std::string, unsigned int> cameraIdsMap_;
+	std::vector<std::unique_ptr<CameraDevice>> cameras_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
+	std::map<std::string, unsigned int> cameraIdsMap_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
 	libcamera::Mutex mutex_;
 
 	unsigned int numInternalCameras_;