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:02:47 +1100 |
commit | f58eb9844051479062f9c4dcb69da46d001625da (patch) | |
tree | 920bc94cbf447e3ede2accea10b962508d8eee86 /gst-libs | |
parent | b1fd1d34bd3e6e0402d56efee5bc7b88fffdf895 (diff) | |
download | gstreamer-plugins-bad-f58eb9844051479062f9c4dcb69da46d001625da.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
Diffstat (limited to 'gst-libs')
-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 5752ae2d4..1e1be6d09 100644 --- a/gst-libs/gst/gl/gstglwindow.c +++ b/gst-libs/gst/gl/gstglwindow.c @@ -87,7 +87,6 @@ static void gst_gl_window_default_send_message_async (GstGLWindow * window, struct _GstGLWindowPrivate { - GMainContext *main_context; GMainLoop *loop; guint surface_width; @@ -168,8 +167,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); } static void @@ -294,8 +293,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); @@ -484,27 +484,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); } /** @@ -664,7 +648,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 9aaef05e8..ccb19efcb 100644 --- a/gst-libs/gst/gl/gstglwindow.h +++ b/gst-libs/gst/gl/gstglwindow.h @@ -85,6 +85,7 @@ struct _GstGLWindow { GstGLDisplay *display; GWeakRef context_ref; + /*< protected >*/ gboolean is_drawing; GstGLWindowCB draw; @@ -99,6 +100,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 5d2efc956..933ddfe41 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 c306a6b06..dd1174544 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; } |