diff options
author | Matthew Waters <matthew@centricular.com> | 2016-12-15 00:59:45 +1100 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2016-12-16 00:10:33 +1100 |
commit | 3aaf645c7d16a01b49325367ab8403a73c4d624c (patch) | |
tree | 96b7947498dad981835739a9398db9b9e87cab53 | |
parent | c9215f5fad947008b53c886959c2379ebf802869 (diff) | |
download | gstreamer-plugins-bad-3aaf645c7d16a01b49325367ab8403a73c4d624c.tar.gz |
gl/window: remove use of main_context_push/pop_thread_default()
No-one's using/depending on it (it would have criticalled and not worked)
and it's causing more problems than it's solving. Store the GMainContext
in the public struct instead for subclasses to optionally use instead of
relying on the push/pop state to be correct.
https://bugzilla.gnome.org/show_bug.cgi?id=775970
-rw-r--r-- | gst-libs/gst/gl/gstglwindow.c | 32 | ||||
-rw-r--r-- | gst-libs/gst/gl/gstglwindow.h | 3 | ||||
-rw-r--r-- | gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c | 2 | ||||
-rw-r--r-- | gst-libs/gst/gl/win32/gstglwindow_win32.c | 3 |
4 files changed, 13 insertions, 27 deletions
diff --git a/gst-libs/gst/gl/gstglwindow.c b/gst-libs/gst/gl/gstglwindow.c index 7a275e4f5..e037ad293 100644 --- a/gst-libs/gst/gl/gstglwindow.c +++ b/gst-libs/gst/gl/gstglwindow.c @@ -88,7 +88,6 @@ static gpointer gst_gl_window_navigation_thread (GstGLWindow * window); struct _GstGLWindowPrivate { - GMainContext *main_context; GMainLoop *loop; guint surface_width; @@ -180,8 +179,8 @@ gst_gl_window_init (GstGLWindow * window) g_mutex_init (&window->priv->sync_message_lock); g_cond_init (&window->priv->sync_message_cond); - priv->main_context = g_main_context_new (); - priv->loop = g_main_loop_new (priv->main_context, FALSE); + window->main_context = g_main_context_new (); + priv->loop = g_main_loop_new (window->main_context, FALSE); priv->navigation_loop = NULL; } @@ -329,8 +328,9 @@ gst_gl_window_finalize (GObject * object) if (priv->loop) g_main_loop_unref (priv->loop); - if (priv->main_context) - g_main_context_unref (priv->main_context); + if (window->main_context) + g_main_context_unref (window->main_context); + window->main_context = NULL; g_weak_ref_clear (&window->context_ref); @@ -522,27 +522,11 @@ gst_gl_window_default_run (GstGLWindow * window) { 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_context_push_thread_default (window->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); - } + g_main_context_pop_thread_default (window->main_context); } /** @@ -702,7 +686,7 @@ gst_gl_window_default_send_message_async (GstGLWindow * window, message->data = data; message->destroy = destroy; - g_main_context_invoke (priv->main_context, (GSourceFunc) _run_message_async, + g_main_context_invoke (window->main_context, (GSourceFunc) _run_message_async, message); } diff --git a/gst-libs/gst/gl/gstglwindow.h b/gst-libs/gst/gl/gstglwindow.h index a5cc5b4b0..2aacac21d 100644 --- a/gst-libs/gst/gl/gstglwindow.h +++ b/gst-libs/gst/gl/gstglwindow.h @@ -79,6 +79,7 @@ struct _GstGLWindow { guintptr external_gl_context; + /*< protected >*/ gboolean is_drawing; GstGLWindowCB draw; @@ -93,6 +94,8 @@ struct _GstGLWindow { gboolean queue_resize; + GMainContext *main_context; /* default main_context */ + /*< private >*/ GstGLWindowPrivate *priv; diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c index 6e1f0c5b8..338daed1d 100644 --- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c +++ b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c @@ -408,7 +408,7 @@ gst_gl_window_wayland_egl_open (GstGLWindow * window, GError ** error) if (!GST_GL_WINDOW_CLASS (parent_class)->open (window, error)) return FALSE; - g_source_attach (window_egl->wl_source, g_main_context_get_thread_default ()); + g_source_attach (window_egl->wl_source, window->main_context); return TRUE; } diff --git a/gst-libs/gst/gl/win32/gstglwindow_win32.c b/gst-libs/gst/gl/win32/gstglwindow_win32.c index 2c919cd6a..8f31825d8 100644 --- a/gst-libs/gst/gl/win32/gstglwindow_win32.c +++ b/gst-libs/gst/gl/win32/gstglwindow_win32.c @@ -120,8 +120,7 @@ gst_gl_window_win32_open (GstGLWindow * window, GError ** error) window_win32->msg_source = win32_message_source_new (window_win32); g_source_set_callback (window_win32->msg_source, (GSourceFunc) msg_cb, NULL, NULL); - g_source_attach (window_win32->msg_source, - g_main_context_get_thread_default ()); + g_source_attach (window_win32->msg_source, window->main_context); return TRUE; } |