From e7bd332887b97939070b7e145cb3089397143eac Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Sun, 21 Sep 2014 21:30:58 +1000 Subject: [PATCH] glcontext: add API to retreive the thread that context is active in --- docs/libs/gst-plugins-bad-libs-sections.txt | 1 + gst-libs/gst/gl/gstglcontext.c | 24 +++++++++++++++++++++ gst-libs/gst/gl/gstglcontext.h | 1 + 3 files changed, 26 insertions(+) diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt index 55e2a3348a..0d8398694f 100644 --- a/docs/libs/gst-plugins-bad-libs-sections.txt +++ b/docs/libs/gst-plugins-bad-libs-sections.txt @@ -804,6 +804,7 @@ gst_gl_context_get_display gst_gl_context_get_gl_api gst_gl_context_get_gl_context gst_gl_context_get_gl_platform +gst_gl_context_get_thread gst_gl_context_check_feature gst_gl_context_check_gl_version gst_gl_context_get_gl_version diff --git a/gst-libs/gst/gl/gstglcontext.c b/gst-libs/gst/gl/gstglcontext.c index 51ea364e95..78e6f94e45 100644 --- a/gst-libs/gst/gl/gstglcontext.c +++ b/gst-libs/gst/gl/gstglcontext.c @@ -139,6 +139,7 @@ struct _GstGLContextPrivate GstGLDisplay *display; GThread *gl_thread; + GThread *active_thread; /* conditions */ GMutex render_lock; @@ -407,11 +408,34 @@ gst_gl_context_activate (GstGLContext * context, gboolean activate) context_class = GST_GL_CONTEXT_GET_CLASS (context); g_return_val_if_fail (context_class->activate != NULL, FALSE); + GST_OBJECT_LOCK (context); result = context_class->activate (context, activate); + context->priv->active_thread = result + && activate ? context->priv->gl_thread : NULL; + GST_OBJECT_UNLOCK (context); + return result; } +/** + * gst_gl_context_get_thread: + * @context: a #GstGLContext + * + * Returns: The #GThread, @context is current in or NULL + */ +GThread * +gst_gl_context_get_thread (GstGLContext * context) +{ + GThread *ret; + + GST_OBJECT_LOCK (context); + ret = context->priv->active_thread; + GST_OBJECT_UNLOCK (context); + + return ret; +} + /** * gst_gl_context_get_gl_api: * @context: a #GstGLContext diff --git a/gst-libs/gst/gl/gstglcontext.h b/gst-libs/gst/gl/gstglcontext.h index c7df03859c..7d06981647 100644 --- a/gst-libs/gst/gl/gstglcontext.h +++ b/gst-libs/gst/gl/gstglcontext.h @@ -120,6 +120,7 @@ GstGLContext * gst_gl_context_new_wrapped (GstGLDisplay *display, GstGLAPI available_apis); gboolean gst_gl_context_activate (GstGLContext *context, gboolean activate); +GThread * gst_gl_context_get_thread (GstGLContext *context); GstGLDisplay * gst_gl_context_get_display (GstGLContext *context); gpointer gst_gl_context_get_proc_address (GstGLContext *context, const gchar *name);