[libcamera-devel] [PATCH v1 04/23] gst: utils: Add a macro to use a GMutexLocker
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Feb 11 19:00:26 CET 2020
Hi Nicolas,
Thank you for the patch.
On Tue, Jan 28, 2020 at 10:31:51PM -0500, Nicolas Dufresne wrote:
> From: Nicolas Dufresne <nicolas.dufresne at collabora.com>
>
> The GMutexLocker uses GCC/CLANG C feature to implement a smart lock,
s/smart/scoped/ ?
> 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))
> +
The name of the macro would lead me to think it's provided by gstreamer.
Should it be renamed to GST_LIBCAMERA_OBJECT_LOCKER() ? Or would that
be too long ?
> GstCaps *gst_libcamera_stream_formats_to_caps(const libcamera::StreamFormats &formats);
>
> #endif /* __GST_LIBCAMERA_UTILS_H_ */
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list