[libcamera-devel] [RFC PATCH 6/6] android: camera_request: Add thread safety annotation

Hirokazu Honda hiroh at chromium.org
Fri Oct 29 06:14:24 CEST 2021


This applies clang thread safety annotation to
Camera3RequestDescriptor. Mutex and MutexLocker there are
replaced with Mutex2 and MutexLocer2.

Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
---
 src/android/camera_request.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/android/camera_request.h b/src/android/camera_request.h
index cfafa445..0c8e7287 100644
--- a/src/android/camera_request.h
+++ b/src/android/camera_request.h
@@ -9,10 +9,11 @@
 
 #include <map>
 #include <memory>
-#include <mutex>
 #include <vector>
 
 #include <libcamera/base/class.h>
+#include <libcamera/base/mutex.h>
+#include <libcamera/base/thread_annotations.h>
 
 #include <libcamera/camera.h>
 #include <libcamera/framebuffer.h>
@@ -46,8 +47,8 @@ public:
 	};
 
 	/* Keeps track of streams requiring post-processing. */
-	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_;
-	std::mutex streamsProcessMutex_;
+	std::map<CameraStream *, StreamBuffer *> pendingStreamsToProcess_ GUARDED_BY(streamsProcessMutex_);
+	libcamera::Mutex2 streamsProcessMutex_;
 
 	Camera3RequestDescriptor(libcamera::Camera *camera,
 				 const camera3_capture_request_t *camera3Request);
-- 
2.33.1.1089.g2158813163f-goog



More information about the libcamera-devel mailing list