summaryrefslogtreecommitdiff
path: root/ext/wpe
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2020-08-15 02:02:44 +1000
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-11-15 15:27:08 +0000
commit92472ef0887e2eb817c8250b4273601738f6ca11 (patch)
treecab4f456470485ba3c887b8ed0dcbfc44f795008 /ext/wpe
parentc118ae11ab9a25f450926c9e23fee6c510fb6ba8 (diff)
downloadgstreamer-plugins-bad-92472ef0887e2eb817c8250b4273601738f6ca11.tar.gz
wpe: Don't crash when running on X11.
Don't assume the available EGL display is a wayland display - instead, check the the GStreamer GL context is EGL, and then use gst_gl_display_egl_from_gl_display to create a GstGLDisplayEGL from that, which also adds refcounting around the underlying EGLDisplay. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1385 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1752>
Diffstat (limited to 'ext/wpe')
-rw-r--r--ext/wpe/WPEThreadedView.cpp26
-rw-r--r--ext/wpe/WPEThreadedView.h4
2 files changed, 22 insertions, 8 deletions
diff --git a/ext/wpe/WPEThreadedView.cpp b/ext/wpe/WPEThreadedView.cpp
index bd0ff6359..d95c29869 100644
--- a/ext/wpe/WPEThreadedView.cpp
+++ b/ext/wpe/WPEThreadedView.cpp
@@ -214,18 +214,25 @@ WPEView::WPEView(WebKitWebContext* web_context, GstWpeSrc* src, GstGLContext* co
g_mutex_init(&images_mutex);
if (context)
gst.context = GST_GL_CONTEXT(gst_object_ref(context));
- if (display)
+ if (display) {
gst.display = GST_GL_DISPLAY(gst_object_ref(display));
+ }
wpe.width = width;
wpe.height = height;
- EGLDisplay eglDisplay = EGL_NO_DISPLAY;
- if (context && display)
- eglDisplay = gst_gl_display_egl_get_from_native(GST_GL_DISPLAY_TYPE_WAYLAND, gst_gl_display_get_handle(display));
- GST_DEBUG("eglDisplay %p", eglDisplay);
+ if (context && display) {
+ if (gst_gl_context_get_gl_platform(context) == GST_GL_PLATFORM_EGL) {
+ gst.display_egl = gst_gl_display_egl_from_gl_display (gst.display);
+ } else {
+ GST_DEBUG ("Available GStreamer GL Context is not EGL - not creating an EGL display from it");
+ }
+ }
+
+ if (gst.display_egl) {
+ EGLDisplay eglDisplay = (EGLDisplay)gst_gl_display_get_handle (GST_GL_DISPLAY(gst.display_egl));
+ GST_DEBUG("eglDisplay %p", eglDisplay);
- if (eglDisplay) {
m_isValid = wpe_fdo_initialize_for_egl_display(eglDisplay);
GST_DEBUG("FDO EGL display initialisation result: %d", m_isValid);
} else {
@@ -239,7 +246,7 @@ WPEView::WPEView(WebKitWebContext* web_context, GstWpeSrc* src, GstGLContext* co
if (!m_isValid)
return;
- if (eglDisplay) {
+ if (gst.display_egl) {
wpe.exportable = wpe_view_backend_exportable_fdo_egl_create(&s_exportableEGLClient, this, wpe.width, wpe.height);
} else {
#if ENABLE_SHM_BUFFER_SUPPORT
@@ -305,6 +312,11 @@ WPEView::~WPEView()
}
});
+ if (gst.display_egl) {
+ gst_object_unref(gst.display_egl);
+ gst.display_egl = nullptr;
+ }
+
if (gst.display) {
gst_object_unref(gst.display);
gst.display = nullptr;
diff --git a/ext/wpe/WPEThreadedView.h b/ext/wpe/WPEThreadedView.h
index c5633abc5..a4b5ae22d 100644
--- a/ext/wpe/WPEThreadedView.h
+++ b/ext/wpe/WPEThreadedView.h
@@ -22,6 +22,7 @@
#include <EGL/egl.h>
#include <glib.h>
#include <gst/gl/gstglfuncs.h>
+#include <gst/gl/egl/gstgldisplay_egl.h>
#include <wpe/fdo.h>
#include <wpe/fdo-egl.h>
#include <wpe/webkit.h>
@@ -82,7 +83,8 @@ private:
struct {
GstGLContext* context;
GstGLDisplay* display;
- } gst { nullptr, nullptr };
+ GstGLDisplayEGL* display_egl;
+ } gst { nullptr, nullptr, nullptr };
static struct wpe_view_backend_exportable_fdo_egl_client s_exportableEGLClient;
#if ENABLE_SHM_BUFFER_SUPPORT