summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Normand <philn@igalia.com>2021-09-18 12:01:39 +0100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-09-20 14:44:19 +0000
commit4af3442d4aef31897de87d4cde15102b5d773003 (patch)
tree7196d7634e85924fa4b0dd0f914b45c20b0773fa
parent9dfd2377416d0f6396885b738a1de83bb71227ee (diff)
wpe: Properly wait on context thread startup condition
Fixes #1661 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2533>
-rw-r--r--ext/wpe/WPEThreadedView.cpp5
-rw-r--r--ext/wpe/WPEThreadedView.h1
2 files changed, 5 insertions, 1 deletions
diff --git a/ext/wpe/WPEThreadedView.cpp b/ext/wpe/WPEThreadedView.cpp
index 7d1e5f21d..cbc5b9f4b 100644
--- a/ext/wpe/WPEThreadedView.cpp
+++ b/ext/wpe/WPEThreadedView.cpp
@@ -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;
},
diff --git a/ext/wpe/WPEThreadedView.h b/ext/wpe/WPEThreadedView.h
index bc126d13c..6089251c3 100644
--- a/ext/wpe/WPEThreadedView.h
+++ b/ext/wpe/WPEThreadedView.h
@@ -138,6 +138,7 @@ private:
struct {
GMutex mutex;
GCond cond;
+ gboolean ready;
GThread* thread { nullptr };
} threading;