wpe: Properly wait on context thread startup condition

Fixes #1661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2533>
This commit is contained in:
Philippe Normand 2021-09-18 12:01:39 +01:00 committed by GStreamer Marge Bot
parent 9dfd237741
commit 4af3442d4a
2 changed files with 5 additions and 1 deletions

View 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;
},

View file

@ -138,6 +138,7 @@ private:
struct {
GMutex mutex;
GCond cond;
gboolean ready;
GThread* thread { nullptr };
} threading;