[vlc-commits] EGL: add CheckClientExt() helper

Rémi Denis-Courmont git at videolan.org
Sun Nov 3 15:26:16 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Nov  3 12:31:29 2013 +0200| [2a1feab2a2abe53fbcfc637358dc96dc1e268b32] | committer: Rémi Denis-Courmont

EGL: add CheckClientExt() helper

Checks support for a EGL client extension.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2a1feab2a2abe53fbcfc637358dc96dc1e268b32
---

 modules/video_output/egl.c |   32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/modules/video_output/egl.c b/modules/video_output/egl.c
index dc0fa64..46dcac6 100644
--- a/modules/video_output/egl.c
+++ b/modules/video_output/egl.c
@@ -79,27 +79,35 @@ static void ReleaseCurrent (vlc_gl_t *);
 static void SwapBuffers (vlc_gl_t *);
 static void *GetSymbol(vlc_gl_t *, const char *);
 
-static bool CheckAPI (EGLDisplay dpy, const char *api)
+static bool CheckToken(const char *haystack, const char *needle)
 {
-    const char *apis = eglQueryString (dpy, EGL_CLIENT_APIS);
-    size_t apilen = strlen (api);
+    size_t len = strlen(needle);
 
-    /* Cannot use strtok_r() on constant string... */
-    do
+    while (haystack != NULL)
     {
-        while (*apis == ' ')
-            apis++;
-        if (!strncmp (apis, api, apilen)
-          && (memchr (" ", apis[apilen], 2) != NULL))
+        while (*haystack == ' ')
+            haystack++;
+        if (!strncmp(haystack, needle, len)
+         && (memchr(" ", haystack[len], 2) != NULL))
             return true;
 
-        apis = strchr (apis, ' ');
+        haystack = strchr(haystack, ' ');
     }
-    while (apis != NULL);
-
     return false;
 }
 
+static bool CheckAPI (EGLDisplay dpy, const char *api)
+{
+    const char *apis = eglQueryString (dpy, EGL_CLIENT_APIS);
+    return CheckToken(apis, api);
+}
+
+static bool CheckClientExt(const char *name)
+{
+    const char *exts = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+    return CheckToken(exts, name);
+}
+
 struct gl_api
 {
    const char name[10];



More information about the vlc-commits mailing list