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
This commit is contained in:
Rafał Dzięgiel
2025-05-25 15:06:26 +02:00
parent 682ad6c3c8
commit db61b9c773

View File

@@ -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));