<html><head></head><body>Hi,<br><br>I don't think memory management / avoiding UB belongs in a VLC object flag. This looks more or less like action at a distance anti-pattern.<br><br>IMO, the flag should be conveyed explicitly by the window to the provider.<br><br><div class="gmail_quote">Le 25 septembre 2019 12:31:51 GMT+03:00, Alexandre Janniaux <ajanni@videolabs.io> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">If a window provider is using EGL with the same display, the EGL state<br>should be terminated from there instead of from the vlc_gl_t provider.<hr> modules/video_output/opengl/egl.c | 13 ++++++++++++-<br> 1 file changed, 12 insertions(+), 1 deletion(-)<br><br>diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/opengl/egl.c<br>index 53d770365ad..6d6ab05738f 100644<br>--- a/modules/video_output/opengl/egl.c<br>+++ b/modules/video_output/opengl/egl.c<br>@@ -56,6 +56,8 @@ typedef struct vlc_gl_sys_t<br> #endif<br>     PFNEGLCREATEIMAGEKHRPROC    eglCreateImageKHR;<br>     PFNEGLDESTROYIMAGEKHRPROC   eglDestroyImageKHR;<br>+<br>+    bool prevent_terminate;<br> } vlc_gl_sys_t;<br> <br> static int MakeCurrent (vlc_gl_t *gl)<br>@@ -185,7 +187,11 @@ static void Close(vlc_gl_t *gl)<br>             eglDestroyContext(sys->display, sys->context);<br>         if (sys->surface != EGL_NO_SURFACE)<br>             eglDestroySurface(sys->display, sys->surface);<br>-        eglTerminate(sys->display);<br>+<br>+        /* Kill the egl state only if we own it. */<br>+        if (!sys->prevent_terminate)<br>+            eglTerminate(sys->display);<br>+        eglReleaseThread();<br>     }<br> #ifdef USE_PLATFORM_X11<br>     if (sys->x11 != NULL)<br>@@ -224,6 +230,10 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,<br>         = CreateWindowSurface;<br>     void *window;<br> <br>+    /* Window providers can prevent the EGL implementation from destroying<br>+     * the associated EGL display. */<br>+    sys->prevent_terminate = var_GetBool(wnd, "egl-prevent-terminate");<br>+<br> #ifdef USE_PLATFORM_X11<br>     sys->x11 = NULL;<br> <br>@@ -319,6 +329,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,<br>     EGLint major, minor;<br>     if (eglInitialize(sys->display, &major, &minor) != EGL_TRUE)<br>         goto error;<br>+<br>     msg_Dbg(obj, "EGL version %s by %s",<br>             eglQueryString(sys->display, EGL_VERSION),<br>             eglQueryString(sys->display, EGL_VENDOR));</pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>