From: Gwenole Beauchesne Date: Tue, 18 Oct 2011 12:25:52 +0000 (+0200) Subject: va: generate __vaDriverInit_*() function name at run-time. X-Git-Tag: libva-1.0.15~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F52%2F852%2F1;p=profile%2Fivi%2Flibva.git va: generate __vaDriverInit_*() function name at run-time. Signed-off-by: Gwenole Beauchesne --- diff --git a/configure.ac b/configure.ac index e618337..00b047b 100644 --- a/configure.ac +++ b/configure.ac @@ -125,14 +125,6 @@ AM_CONDITIONAL(USE_GLX, test "$USE_GLX" = "yes") USE_EGL="yes" AM_CONDITIONAL(USE_EGL, test "$USE_EGL" = "yes") - -# Make sure drivers use the correctly versioned __vaDriverInit*() function name -VA_DRIVER_INIT_FUNC="__vaDriverInit_${LIBVA_MAJOR_VERSION}_${LIBVA_MINOR_VERSION}" -AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC], [$VA_DRIVER_INIT_FUNC], - [Defined to the versioned __vaDriverInit function name]) -AC_DEFINE_UNQUOTED([VA_DRIVER_INIT_FUNC_S], ["$VA_DRIVER_INIT_FUNC"], - [Defined to the versioned __vaDriverInit function name (in string form)]) - # We only need the headers, we don't link against the DRM libraries LIBVA_CFLAGS="$DRM_CFLAGS" AC_SUBST(LIBVA_CFLAGS) diff --git a/va/va.c b/va/va.c index 450b88f..aab00f0 100644 --- a/va/va.c +++ b/va/va.c @@ -149,6 +149,13 @@ static Bool va_checkString(const char* value, char *variable) return True; } +static inline int +va_getDriverInitName(char *name, int namelen, int major, int minor) +{ + int ret = snprintf(name, namelen, "__vaDriverInit_%d_%d", major, minor); + return ret > 0 && ret < namelen; +} + static VAStatus va_getDriverName(VADisplay dpy, char **driver_name) { VADisplayContextP pDisplayContext = (VADisplayContextP)dpy; @@ -193,10 +200,14 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) if (0 == access( driver_path, F_OK)) va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror()); } else { - VADriverInit init_func; - init_func = (VADriverInit) dlsym(handle, VA_DRIVER_INIT_FUNC_S); + VADriverInit init_func = NULL; + char init_func_s[256]; + if (va_getDriverInitName(init_func_s, sizeof(init_func_s), + VA_MAJOR_VERSION, VA_MINOR_VERSION)) + init_func = (VADriverInit) dlsym(handle, init_func_s); if (!init_func) { - va_errorMessage("%s has no function %s\n", driver_path, VA_DRIVER_INIT_FUNC_S); + va_errorMessage("%s has no function %s\n", + driver_path, init_func_s); dlclose(handle); } else { struct VADriverVTable *vtable = ctx->vtable;