From 4af3442d4aef31897de87d4cde15102b5d773003 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Sat, 18 Sep 2021 12:01:39 +0100 Subject: wpe: Properly wait on context thread startup condition Fixes #1661 Part-of: --- ext/wpe/WPEThreadedView.cpp | 5 ++++- ext/wpe/WPEThreadedView.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'ext') 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(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; -- cgit v1.2.1