From db61b9c77309f988ecd0b25c18cfd01705b5087f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sun, 25 May 2025 15:06:26 +0200 Subject: [PATCH] gst-plugin: Avoid main thread invoke when used with "ClapperGtkVideo" This thread invoke is done mainly to support testing with gst-launch-1.0, otherwise no need when used with "ClapperGtkVideo". We can avoid doing this, by checking whether this type was already registered in which case it means that "ClapperGtkVideo" widget is used within GTK application and registered before sink starts processing data. In case of "ClapperGtkVideo" we might run into situation where these two threads are stuck waiting for each other to be idle. This change works around this issue. Fixes #555 --- src/lib/gst/plugin/gstclappersink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/gst/plugin/gstclappersink.c b/src/lib/gst/plugin/gstclappersink.c index 0672f31c..fe1d0220 100644 --- a/src/lib/gst/plugin/gstclappersink.c +++ b/src/lib/gst/plugin/gstclappersink.c @@ -594,11 +594,14 @@ static gboolean gst_clapper_sink_start (GstBaseSink *bsink) { GstClapperSink *self = GST_CLAPPER_SINK_CAST (bsink); + gboolean with_clapper_gtk; GST_INFO_OBJECT (self, "Start"); - if (G_UNLIKELY (!(! !gst_gtk_invoke_on_main ((GThreadFunc) (GCallback) - gst_clapper_sink_start_on_main, self)))) { + with_clapper_gtk = g_type_from_name ("ClapperGtkVideo"); + + if (G_UNLIKELY (!with_clapper_gtk && !(! !gst_gtk_invoke_on_main ( + (GThreadFunc) (GCallback) gst_clapper_sink_start_on_main, self)))) { GST_ELEMENT_ERROR (self, RESOURCE, NOT_FOUND, ("GtkWidget could not be created"), (NULL));