<html><head></head><body>Hi,<br><br>If it's a compile-time constant, better keep it a compile time constant than store it in memory IMO.<br><br><div class="gmail_quote">Le 25 septembre 2019 11:24:40 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">EGL_KHR_display_reference specifies the behaviour of eglTerminate<br>with regards to reference counting. In addition, it specifies that<br>the default is that reference counting is disabled X11 or wayland,<br>but enabled on Android.<br><br>As we can prevent EGL GL provider from terminating its state, it<br>makes sure the state is correctly refcounted in any case.<hr> modules/video_output/opengl/egl.c | 23 +++++++++++++++++++++--<br> 1 file changed, 21 insertions(+), 2 deletions(-)<br><br>diff --git a/modules/video_output/opengl/egl.c b/modules/video_output/opengl/egl.c<br>index 6d6ab05738f..dd8e0cf9887 100644<br>--- a/modules/video_output/opengl/egl.c<br>+++ b/modules/video_output/opengl/egl.c<br>@@ -58,6 +58,7 @@ typedef struct vlc_gl_sys_t<br> PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR;<br> <br> bool prevent_terminate;<br>+ bool has_display_reference;<br> } vlc_gl_sys_t;<br> <br> static int MakeCurrent (vlc_gl_t *gl)<br>@@ -188,8 +189,10 @@ static void Close(vlc_gl_t *gl)<br> if (sys->surface != EGL_NO_SURFACE)<br> eglDestroySurface(sys->display, sys->surface);<br> <br>- /* Kill the egl state only if we own it. */<br>- if (!sys->prevent_terminate)<br>+ /* If has_display_reference == true, sys->display is refcounted by<br>+ * eglInitialize and eglTerminate, so call it anyway.<br>+ * Otherwise, kill the egl state only if we own it. */<br>+ if (sys->has_display_reference || !sys->prevent_terminate)<br> eglTerminate(sys->display);<br> eglReleaseThread();<br> }<br>@@ -224,6 +227,7 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,<br> sys->surface = EGL_NO_SURFACE;<br> sys->eglCreateImageKHR = NULL;<br> sys->eglDestroyImageKHR = NULL;<br>+ sys->has_display_reference = false;<br> <br> vout_window_t *wnd = gl->surface;<br> EGLSurface (*createSurface)(EGLDisplay, EGLConfig, void *, const EGLint *)<br>@@ -234,6 +238,21 @@ static int Open(vlc_gl_t *gl, const struct gl_api *api,<br> * the associated EGL display. */<br> sys->prevent_terminate = var_GetBool(wnd, "egl-prevent-terminate");<br> <br>+ /* See <a href="https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_display_reference.txt">https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_display_reference.txt</a> */<br>+ /* If EGL_KHR_display_reference is not present, eglTerminate will<br>+ * terminate the EGLDisplay which is shared between all clients.<br>+ * This extension turns the behaviour of eglTerminate into reference<br>+ * counting mode and prevents this issues.<br>+ * TODO: currently, we're using the default behaviour of this extension. */<br>+#ifdef USE_PLATFORM_ANDROID<br>+ sys->has_display_reference = true; /* enforced by Android */<br>+#else<br>+ /* If we don't conditionnaly add the EGL_TRACK_REFERENCE_KHR, EGL_TRUE<br>+ * parameter to display query parameters, the default is false for other<br>+ * platforms. */<br>+ sys->has_display_reference = false;<br>+#endif<br>+<br> #ifdef USE_PLATFORM_X11<br> sys->x11 = NULL;<br> </pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>