[libcamera-devel] [PATCH] Apply review suggestions

Cedric Nugteren cedric at plumerai.com
Fri Jun 2 15:38:05 CEST 2023


This addresses the comments from Nicolas. I did not change the default behaviour,
I'll wait with that until you have settled on what to do.

Signed-off-by: Cedric Nugteren <web at cedricnugteren.nl>
---
 src/gstreamer/gstlibcameraprovider.cpp | 15 +++++++--------
 src/gstreamer/gstlibcamerasrc.cpp      | 14 +++++++-------
 2 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/gstreamer/gstlibcameraprovider.cpp b/src/gstreamer/gstlibcameraprovider.cpp
index 86fa2542..579cb8c0 100644
--- a/src/gstreamer/gstlibcameraprovider.cpp
+++ b/src/gstreamer/gstlibcameraprovider.cpp
@@ -41,7 +41,7 @@ G_DECLARE_FINAL_TYPE(GstLibcameraDevice, gst_libcamera_device,
 struct _GstLibcameraDevice {
 	GstDevice parent;
 	gchar *name;
-	gboolean enable_auto_focus = false;
+	bool enable_auto_focus = false;
 };
 
 G_DEFINE_TYPE(GstLibcameraDevice, gst_libcamera_device, GST_TYPE_DEVICE)
@@ -71,7 +71,6 @@ gst_libcamera_device_reconfigure_element(GstDevice *device,
 		return FALSE;
 
 	g_object_set(element, "camera-name", GST_LIBCAMERA_DEVICE(device)->name, nullptr);
-	g_object_set(element, "enable-auto-focus", GST_LIBCAMERA_DEVICE(device)->enable_auto_focus, nullptr);
 
 	return TRUE;
 }
@@ -128,12 +127,12 @@ gst_libcamera_device_class_init(GstLibcameraDeviceClass *klass)
 						(GParamFlags)(G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE |
 							      G_PARAM_CONSTRUCT_ONLY));
 	g_object_class_install_property(object_class, PROP_DEVICE_NAME, pspec);
-	GParamSpec *spec2 = g_param_spec_boolean("enable-auto-focus",
-	                        "Enable auto-focus",
-	                        "Enable auto-focus if set to true, "
-	                        "disable it if set to false",
-	                         FALSE, G_PARAM_WRITABLE);
-	g_object_class_install_property(object_class, PROP_ENABLE_AUTO_FOCUS, spec2);
+	pspec = g_param_spec_boolean("enable-auto-focus",
+	                             "Enable auto-focus",
+	                             "Enable auto-focus if set to true, "
+	                             "disable it if set to false",
+	                              FALSE, G_PARAM_WRITABLE);
+	g_object_class_install_property(object_class, PROP_ENABLE_AUTO_FOCUS, pspec);
 }
 
 static GstDevice *
diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 672ea38a..b2d8456b 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -146,7 +146,7 @@ struct _GstLibcameraSrc {
 	GstTask *task;
 
 	gchar *camera_name;
-	gboolean enable_auto_focus = false;
+	bool enable_auto_focus = false;
 
 	GstLibcameraSrcState *state;
 	GstLibcameraAllocator *allocator;
@@ -864,11 +864,11 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)
 							     | G_PARAM_READWRITE
 							     | G_PARAM_STATIC_STRINGS));
 	g_object_class_install_property(object_class, PROP_CAMERA_NAME, spec);
-	GParamSpec *spec2 = g_param_spec_boolean("enable-auto-focus",
-	                        "Enable auto-focus",
-	                        "Enable auto-focus if set to true, "
-	                        "disable it if set to false",
-	                         FALSE, G_PARAM_WRITABLE);
-	g_object_class_install_property(object_class, PROP_ENABLE_AUTO_FOCUS, spec2);
+	spec = g_param_spec_boolean("enable-auto-focus",
+	                            "Enable auto-focus",
+	                            "Enable auto-focus if set to true, "
+	                            "disable it if set to false",
+	                             FALSE, G_PARAM_WRITABLE);
+	g_object_class_install_property(object_class, PROP_ENABLE_AUTO_FOCUS, spec);
 
 }
-- 
2.34.1



More information about the libcamera-devel mailing list