qt/6: mark GstGLDisplayEGLs that would be created as foreign

Otherwise, GStreamer may preemptively call eglTerminate() before Qt has
finished using the EGLDisplay.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8504>
This commit is contained in:
Matthew Waters 2025-02-18 16:46:15 +11:00 committed by GStreamer Marge Bot
parent ddf7c1ec63
commit b2a5b4f304
2 changed files with 22 additions and 4 deletions

View File

@ -102,12 +102,18 @@ gst_qt_get_gl_display (gboolean sink)
if (QString::fromUtf8 ("wayland") == app->platformName() if (QString::fromUtf8 ("wayland") == app->platformName()
|| QString::fromUtf8 ("wayland-egl") == app->platformName()){ || QString::fromUtf8 ("wayland-egl") == app->platformName()){
struct wl_display * wayland_display; struct wl_display * wayland_display;
GstGLDisplayEGL *display_egl;
QPlatformNativeInterface *native = QPlatformNativeInterface *native =
QGuiApplication::platformNativeInterface(); QGuiApplication::platformNativeInterface();
wayland_display = (struct wl_display *) wayland_display = (struct wl_display *)
native->nativeResourceForWindow("display", NULL); native->nativeResourceForWindow("display", NULL);
display = (GstGLDisplay *) display = (GstGLDisplay *)
gst_gl_display_wayland_new_with_display (wayland_display); gst_gl_display_wayland_new_with_display (wayland_display);
display_egl = gst_gl_display_egl_from_gl_display (display);
if (display_egl)
gst_gl_display_egl_set_foreign (display_egl, TRUE);
gst_clear_object (&display_egl);
} }
#endif #endif
#if GST_GL_HAVE_PLATFORM_EGL && GST_GL_HAVE_WINDOW_ANDROID #if GST_GL_HAVE_PLATFORM_EGL && GST_GL_HAVE_WINDOW_ANDROID
@ -144,8 +150,11 @@ gst_qt_get_gl_display (gboolean sink)
QGuiApplication::platformNativeInterface(); QGuiApplication::platformNativeInterface();
EGLDisplay egl_display = (EGLDisplay) EGLDisplay egl_display = (EGLDisplay)
native->nativeResourceForWindow("egldisplay", NULL); native->nativeResourceForWindow("egldisplay", NULL);
if (egl_display != EGL_NO_DISPLAY) if (egl_display != EGL_NO_DISPLAY) {
display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display); GstGLDisplayEGL *display_egl = gst_gl_display_egl_new_with_egl_display (egl_display);
gst_gl_display_egl_set_foreign (display_egl, TRUE);
display = (GstGLDisplay *) display_egl;
}
#else #else
EGLDisplay egl_display = (EGLDisplay) gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0); EGLDisplay egl_display = (EGLDisplay) gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0);
display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display); display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display);

View File

@ -102,12 +102,18 @@ gst_qml6_get_gl_display (gboolean sink)
if (QString::fromUtf8 ("wayland") == app->platformName() if (QString::fromUtf8 ("wayland") == app->platformName()
|| QString::fromUtf8 ("wayland-egl") == app->platformName()){ || QString::fromUtf8 ("wayland-egl") == app->platformName()){
struct wl_display * wayland_display; struct wl_display * wayland_display;
GstGLDisplayEGL *display_egl;
QPlatformNativeInterface *native = QPlatformNativeInterface *native =
QGuiApplication::platformNativeInterface(); QGuiApplication::platformNativeInterface();
wayland_display = (struct wl_display *) wayland_display = (struct wl_display *)
native->nativeResourceForWindow("display", NULL); native->nativeResourceForWindow("display", NULL);
display = (GstGLDisplay *) display = (GstGLDisplay *)
gst_gl_display_wayland_new_with_display (wayland_display); gst_gl_display_wayland_new_with_display (wayland_display);
display_egl = gst_gl_display_egl_from_gl_display (display);
if (display_egl)
gst_gl_display_egl_set_foreign (display_egl, TRUE);
gst_clear_object (&display_egl);
} }
#endif #endif
#if GST_GL_HAVE_PLATFORM_EGL && GST_GL_HAVE_WINDOW_ANDROID #if GST_GL_HAVE_PLATFORM_EGL && GST_GL_HAVE_WINDOW_ANDROID
@ -144,8 +150,11 @@ gst_qml6_get_gl_display (gboolean sink)
QGuiApplication::platformNativeInterface(); QGuiApplication::platformNativeInterface();
EGLDisplay egl_display = (EGLDisplay) EGLDisplay egl_display = (EGLDisplay)
native->nativeResourceForWindow("egldisplay", NULL); native->nativeResourceForWindow("egldisplay", NULL);
if (egl_display != EGL_NO_DISPLAY) if (egl_display != EGL_NO_DISPLAY) {
display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display); GstGLDisplayEGL *display_egl = gst_gl_display_egl_new_with_egl_display (egl_display);
gst_gl_display_egl_set_foreign (display_egl, TRUE);
display = (GstGLDisplay *) display_egl;
}
#else #else
EGLDisplay egl_display = (EGLDisplay) gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0); EGLDisplay egl_display = (EGLDisplay) gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_ANY, 0);
display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display); display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display);