[libcamera-devel] [PATCH v1 04/23] gst: utils: Add a macro to use a GMutexLocker
Nicolas Dufresne
nicolas at ndufresne.ca
Wed Jan 29 04:31:51 CET 2020
From: Nicolas Dufresne <nicolas.dufresne at collabora.com>
The GMutexLocker uses GCC/CLANG C feature to implement a smart lock,
that unlocks the mutex when the GMutexLocker goes out of scope. This
could have been implemented in C++, but as this is already implemented
I decided to just reuse it. This is particularly handy to avoid gotos
in error handling cases and to prevent unbalanced locking.
Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>
---
src/gstreamer/gstlibcamera-utils.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/gstreamer/gstlibcamera-utils.h b/src/gstreamer/gstlibcamera-utils.h
index 4545512..528dc2c 100644
--- a/src/gstreamer/gstlibcamera-utils.h
+++ b/src/gstreamer/gstlibcamera-utils.h
@@ -13,6 +13,8 @@
#ifndef __GST_LIBCAMERA_UTILS_H_
+#define GST_OBJECT_LOCKER(obj) g_autoptr(GMutexLocker) locker = g_mutex_locker_new(GST_OBJECT_GET_LOCK(obj))
+
GstCaps *gst_libcamera_stream_formats_to_caps(const libcamera::StreamFormats &formats);
#endif /* __GST_LIBCAMERA_UTILS_H_ */
--
2.24.1
More information about the libcamera-devel
mailing list