From 14b67a2daa146ec5d4278fe5dd7d39c8f4f1d1d9 Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Mon, 12 Aug 2024 15:59:18 +0200 Subject: [PATCH 1/2] gst: remove dead code --- gst/gstaravis.c | 32 -------------------------------- gst/gstaravis.h | 3 +-- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/gst/gstaravis.c b/gst/gstaravis.c index 01818c3e8..3a4469209 100644 --- a/gst/gstaravis.c +++ b/gst/gstaravis.c @@ -215,11 +215,9 @@ gst_aravis_set_caps (GstBaseSrc *src, GstCaps *caps) gint current_height, current_width; int depth = 0, bpp = 0; const GValue *frame_rate = NULL; - const char *caps_string; const char *format_string; unsigned int i; ArvStream *orig_stream = NULL; - GstCaps *orig_fixed_caps = NULL; gboolean result = FALSE; gboolean is_frame_rate_available; gboolean is_gain_available; @@ -342,29 +340,6 @@ gst_aravis_set_caps (GstBaseSrc *src, GstCaps *caps) GST_DEBUG_OBJECT (gst_aravis, "Actual exposure = %g µs", arv_camera_get_exposure_time (gst_aravis->camera, NULL)); } - orig_fixed_caps = g_steal_pointer (&gst_aravis->fixed_caps); - - caps_string = arv_pixel_format_to_gst_caps_string (pixel_format); - if (caps_string != NULL) { - GstStructure *structure; - GstCaps *caps; - - caps = gst_caps_new_empty (); - structure = gst_structure_from_string (caps_string, NULL); - gst_structure_set (structure, - "width", G_TYPE_INT, width, - "height", G_TYPE_INT, height, - NULL); - - if (frame_rate != NULL) - gst_structure_set_value (structure, "framerate", frame_rate); - - gst_caps_append_structure (caps, structure); - - gst_aravis->fixed_caps = caps; - } else - gst_aravis->fixed_caps = NULL; - if (!error) arv_device_set_features_from_string (arv_camera_get_device (gst_aravis->camera), gst_aravis->features, &error); if (!error) gst_aravis->payload = arv_camera_get_payload (gst_aravis->camera, &error); @@ -412,8 +387,6 @@ gst_aravis_set_caps (GstBaseSrc *src, GstCaps *caps) unref: if (orig_stream != NULL) g_object_unref (orig_stream); - if (orig_fixed_caps != NULL) - gst_caps_unref (orig_fixed_caps); return result; } @@ -682,7 +655,6 @@ gst_aravis_init (GstAravis *gst_aravis) gst_aravis->stream = NULL; gst_aravis->all_caps = NULL; - gst_aravis->fixed_caps = NULL; } static void @@ -692,13 +664,11 @@ gst_aravis_finalize (GObject * object) ArvCamera *camera; ArvStream *stream; GstCaps *all_caps; - GstCaps *fixed_caps; GST_OBJECT_LOCK (gst_aravis); camera = g_steal_pointer (&gst_aravis->camera); stream = g_steal_pointer (&gst_aravis->stream); all_caps = g_steal_pointer (&gst_aravis->all_caps); - fixed_caps = g_steal_pointer (&gst_aravis->fixed_caps); g_clear_pointer (&gst_aravis->camera_name, g_free); g_clear_pointer (&gst_aravis->features, g_free); GST_OBJECT_UNLOCK (gst_aravis); @@ -709,8 +679,6 @@ gst_aravis_finalize (GObject * object) g_object_unref (stream); if (all_caps != NULL) gst_caps_unref (all_caps); - if (fixed_caps != NULL) - gst_caps_unref (fixed_caps); G_OBJECT_CLASS (gst_aravis_parent_class)->finalize (object); } diff --git a/gst/gstaravis.h b/gst/gstaravis.h index 5bcbf22c9..6778f62e3 100644 --- a/gst/gstaravis.h +++ b/gst/gstaravis.h @@ -68,13 +68,12 @@ struct _GstAravis { gint payload; guint64 buffer_timeout_us; - gdouble frame_rate; + gdouble frame_rate; ArvCamera *camera; ArvStream *stream; GstCaps *all_caps; - GstCaps *fixed_caps; guint64 timestamp_offset; guint64 last_timestamp; From 40f679ef2c3634e2ed02bdd3f207298ca64d909f Mon Sep 17 00:00:00 2001 From: Emmanuel Pacaud Date: Mon, 12 Aug 2024 16:48:03 +0200 Subject: [PATCH 2/2] gst: disconnect from camera in stop method Otherwise a stopped source can not be restarted, because the camera is still in use. Fix #907 --- gst/gstaravis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gst/gstaravis.c b/gst/gstaravis.c index 3a4469209..0c0445bd3 100644 --- a/gst/gstaravis.c +++ b/gst/gstaravis.c @@ -462,17 +462,21 @@ gst_aravis_stop( GstBaseSrc * src ) { GError *error = NULL; GstAravis* gst_aravis = GST_ARAVIS(src); + ArvCamera *camera; ArvStream *stream; GstCaps *all_caps; GST_OBJECT_LOCK (gst_aravis); arv_camera_stop_acquisition (gst_aravis->camera, &error); + camera = g_steal_pointer (&gst_aravis->camera); stream = g_steal_pointer (&gst_aravis->stream); all_caps = g_steal_pointer (&gst_aravis->all_caps); GST_OBJECT_UNLOCK (gst_aravis); if (stream != NULL) g_object_unref (stream); + if (camera != NULL) + g_object_unref (camera); if (all_caps != NULL) gst_caps_unref (all_caps);