wpe: Properly wait on context thread startup condition
authorPhilippe Normand <philn@igalia.com>
Sat, 18 Sep 2021 11:01:39 +0000 (12:01 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 20 Sep 2021 14:44:19 +0000 (14:44 +0000)
Fixes #1661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2533>

ext/wpe/WPEThreadedView.cpp
ext/wpe/WPEThreadedView.h

index 7d1e5f2..cbc5b9f 100644 (file)
@@ -77,7 +77,9 @@ WPEContextThread::WPEContextThread()
     {
         GMutexHolder lock(threading.mutex);
         threading.thread = g_thread_new("WPEContextThread", s_viewThread, this);
-        g_cond_wait(&threading.cond, &threading.mutex);
+        while (!threading.ready) {
+            g_cond_wait(&threading.cond, &threading.mutex);
+        }
         GST_DEBUG("thread spawned");
     }
 }
@@ -138,6 +140,7 @@ gpointer WPEContextThread::s_viewThread(gpointer data)
             [](gpointer data) -> gboolean {
                 auto& view = *static_cast<WPEContextThread*>(data);
                 GMutexHolder lock(view.threading.mutex);
+                view.threading.ready = TRUE;
                 g_cond_signal(&view.threading.cond);
                 return G_SOURCE_REMOVE;
             },
index bc126d1..6089251 100644 (file)
@@ -138,6 +138,7 @@ private:
     struct {
         GMutex mutex;
         GCond cond;
+        gboolean ready;
         GThread* thread { nullptr };
     } threading;