mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
glwindow: move g_main_context_push/pop_thread_default() to run()
Calling g_main_context_push_thread and then g_main_context_invoke() (used by gst_gl_window_send_message_async()) in the same thread will cause the invoked function to run immediately instead of being delayed. This had implications for the creation of the OpenGL context not waiting until the main loop had completely started up and as a result would sometimes deadlock in short create/destroy scenarios. https://bugzilla.gnome.org/show_bug.cgi?id=775171
This commit is contained in:
parent
25fbc6d877
commit
024e92afe7
1 changed files with 23 additions and 24 deletions
|
@ -134,35 +134,12 @@ gst_gl_window_error_quark (void)
|
|||
static gboolean
|
||||
gst_gl_window_default_open (GstGLWindow * window, GError ** error)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
if (g_main_context_get_thread_default ()) {
|
||||
if (priv->main_context)
|
||||
g_main_context_unref (priv->main_context);
|
||||
if (priv->loop)
|
||||
g_main_loop_unref (priv->loop);
|
||||
priv->main_context = g_main_context_ref_thread_default ();
|
||||
priv->loop = NULL;
|
||||
priv->alive = TRUE;
|
||||
} else {
|
||||
g_main_context_push_thread_default (priv->main_context);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_gl_window_default_close (GstGLWindow * window)
|
||||
{
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
if (!priv->loop) {
|
||||
priv->alive = FALSE;
|
||||
g_main_context_unref (priv->main_context);
|
||||
priv->main_context = NULL;
|
||||
} else {
|
||||
g_main_context_pop_thread_default (priv->main_context);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -505,7 +482,29 @@ gst_gl_window_show (GstGLWindow * window)
|
|||
static void
|
||||
gst_gl_window_default_run (GstGLWindow * window)
|
||||
{
|
||||
g_main_loop_run (window->priv->loop);
|
||||
GstGLWindowPrivate *priv = window->priv;
|
||||
|
||||
if (g_main_context_get_thread_default ()) {
|
||||
if (priv->main_context)
|
||||
g_main_context_unref (priv->main_context);
|
||||
if (priv->loop)
|
||||
g_main_loop_unref (priv->loop);
|
||||
priv->main_context = g_main_context_ref_thread_default ();
|
||||
priv->loop = NULL;
|
||||
priv->alive = TRUE;
|
||||
} else {
|
||||
g_main_context_push_thread_default (priv->main_context);
|
||||
}
|
||||
|
||||
g_main_loop_run (priv->loop);
|
||||
|
||||
if (!priv->loop) {
|
||||
priv->alive = FALSE;
|
||||
g_main_context_unref (priv->main_context);
|
||||
priv->main_context = NULL;
|
||||
} else {
|
||||
g_main_context_pop_thread_default (priv->main_context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue