diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2013-05-10 12:49:06 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2013-05-10 12:50:05 +0200 |
commit | 275e104be637325ac005062817a7d6a48914776d (patch) | |
tree | 11af0dab0e2f80a273cd430d796c9e2525293567 | |
parent | db3d5f92d6f091ca0b9019abf990019a1210a7d6 (diff) | |
download | gstreamer-plugins-bad-275e104be637325ac005062817a7d6a48914776d.tar.gz |
egl: Add destroy notify instead of always calling eglTerminate() on the display
In some scenarios, for example in QtWebKit, might be difficult to obtain full
control on the egl display and it might be only accessible indirectly via
eglGetCurrentDisplay().
https://bugzilla.gnome.org/show_bug.cgi?id=700058
-rw-r--r-- | ext/eglgles/gstegladaptation_egl.c | 2 | ||||
-rw-r--r-- | gst-libs/gst/egl/egl.c | 8 | ||||
-rw-r--r-- | gst-libs/gst/egl/egl.h | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/ext/eglgles/gstegladaptation_egl.c b/ext/eglgles/gstegladaptation_egl.c index f54fb11d3..cecbcd4ab 100644 --- a/ext/eglgles/gstegladaptation_egl.c +++ b/ext/eglgles/gstegladaptation_egl.c @@ -168,7 +168,7 @@ gst_egl_adaptation_init_egl_display (GstEglAdaptationContext * ctx) GST_ERROR_OBJECT (ctx->element, "Could not get EGL display connection"); goto HANDLE_ERROR; /* No EGL error is set by eglGetDisplay() */ } - ctx->display = gst_egl_display_new (display); + ctx->display = gst_egl_display_new (display, (GDestroyNotify) eglTerminate); context = gst_context_new (); gst_context_set_egl_display (context, ctx->display); diff --git a/gst-libs/gst/egl/egl.c b/gst-libs/gst/egl/egl.c index 1c5d04c51..0b0ebcc24 100644 --- a/gst-libs/gst/egl/egl.c +++ b/gst-libs/gst/egl/egl.c @@ -328,16 +328,18 @@ struct _GstEGLDisplay { EGLDisplay display; volatile gint refcount; + GDestroyNotify destroy_notify; }; GstEGLDisplay * -gst_egl_display_new (EGLDisplay display) +gst_egl_display_new (EGLDisplay display, GDestroyNotify destroy_notify) { GstEGLDisplay *gdisplay; gdisplay = g_slice_new (GstEGLDisplay); gdisplay->display = display; gdisplay->refcount = 1; + gdisplay->destroy_notify = destroy_notify; return gdisplay; } @@ -358,8 +360,8 @@ gst_egl_display_unref (GstEGLDisplay * display) g_return_if_fail (display != NULL); if (g_atomic_int_dec_and_test (&display->refcount)) { - if (display->display != EGL_NO_DISPLAY) - eglTerminate (display->display); + if (display->destroy_notify) + display->destroy_notify (display->display); g_slice_free (GstEGLDisplay, display); } } diff --git a/gst-libs/gst/egl/egl.h b/gst-libs/gst/egl/egl.h index fa6464ee4..ebc623322 100644 --- a/gst-libs/gst/egl/egl.h +++ b/gst-libs/gst/egl/egl.h @@ -65,7 +65,7 @@ gboolean gst_context_get_egl_display (GstContext * context, #define GST_TYPE_EGL_DISPLAY (gst_egl_display_get_type()) GType gst_egl_display_get_type (void); -GstEGLDisplay *gst_egl_display_new (EGLDisplay display); +GstEGLDisplay *gst_egl_display_new (EGLDisplay display, GDestroyNotify destroy_notify); GstEGLDisplay *gst_egl_display_ref (GstEGLDisplay * display); void gst_egl_display_unref (GstEGLDisplay * display); EGLDisplay gst_egl_display_get (GstEGLDisplay * display); |