[vlc-devel] [PATCH 1/2] egl: allow window provider to prevent eglTerminate in vlc_gl_t

Alexandre Janniaux ajanni at videolabs.io
Wed Sep 25 10:24:39 CEST 2019


If a window provider is using EGL with the same display, the EGL state
should be terminated from there instead of from the vlc_gl_t provider.
---
 modules/video_output/opengl/egl.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/opengl/egl.c
index 53d770365ad..6d6ab05738f 100644
--- a/modules/video_output/opengl/egl.c
+++ b/modules/video_output/opengl/egl.c
@@ -56,6 +56,8 @@ typedef struct vlc_gl_sys_t
 #endif
     PFNEGLCREATEIMAGEKHRPROC    eglCreateImageKHR;
     PFNEGLDESTROYIMAGEKHRPROC   eglDestroyImageKHR;
+
+    bool prevent_terminate;
 } vlc_gl_sys_t;

 static int MakeCurrent (vlc_gl_t *gl)
@@ -185,7 +187,11 @@ static void Close(vlc_gl_t *gl)
             eglDestroyContext(sys->display, sys->context);
         if (sys->surface != EGL_NO_SURFACE)
             eglDestroySurface(sys->display, sys->surface);
-        eglTerminate(sys->display);
+
+        /* Kill the egl state only if we own it. */
+        if (!sys->prevent_terminate)
+            eglTerminate(sys->display);
+        eglReleaseThread();
     }
 #ifdef USE_PLATFORM_X11
     if (sys->x11 != NULL)
@@ -224,6 +230,10 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
         = CreateWindowSurface;
     void *window;

+    /* Window providers can prevent the EGL implementation from destroying
+     * the associated EGL display. */
+    sys->prevent_terminate = var_GetBool(wnd, "egl-prevent-terminate");
+
 #ifdef USE_PLATFORM_X11
     sys->x11 = NULL;

@@ -319,6 +329,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,
     EGLint major, minor;
     if (eglInitialize(sys->display, &major, &minor) != EGL_TRUE)
         goto error;
+
     msg_Dbg(obj, "EGL version %s by %s",
             eglQueryString(sys->display, EGL_VERSION),
             eglQueryString(sys->display, EGL_VENDOR));
--
2.23.0


More information about the vlc-devel mailing list