diff options
author | Gwenole Beauchesne <gbeauchesne@splitted-desktop.com> | 2010-02-23 09:11:22 +0000 |
---|---|---|
committer | Austin Yuan <shengquan.yuan@gmail.com> | 2010-06-04 11:10:09 +0800 |
commit | cb2ba3ed68b44f883ef0e8c88fbd1991c8b89548 (patch) | |
tree | ff3bba4e9e1d46ecc293ea4031c114f6f97739c6 | |
parent | 632443b24034cc9188ccead53e7f8261cf222d65 (diff) | |
download | libva-cb2ba3ed68b44f883ef0e8c88fbd1991c8b89548.tar.gz |
Move LIBVA_DRIVER_NAME check in vaInitialize().
-rw-r--r-- | va/va.c | 50 | ||||
-rw-r--r-- | va/x11/va_x11.c | 9 |
2 files changed, 31 insertions, 28 deletions
@@ -331,30 +331,42 @@ VAStatus vaInitialize ( int *minor_version /* out */ ) { - char *driver_name = NULL; - VAStatus vaStatus; - - CHECK_DISPLAY(dpy); + const char *driver_name_env = NULL; + char *driver_name = NULL; + VAStatus vaStatus; - va_TraceInit(); + CHECK_DISPLAY(dpy); - va_infoMessage("libva version %s\n", VA_VERSION_S); + va_TraceInit(); - vaStatus = va_getDriverName(dpy, &driver_name); - va_infoMessage("va_getDriverName() returns %d\n", vaStatus); - - if (VA_STATUS_SUCCESS == vaStatus) - { - vaStatus = va_openDriver(dpy, driver_name); - va_infoMessage("va_openDriver() returns %d\n", vaStatus); + va_infoMessage("libva version %s\n", VA_VERSION_S); - *major_version = VA_MAJOR_VERSION; - *minor_version = VA_MINOR_VERSION; - } + driver_name_env = getenv("LIBVA_DRIVER_NAME"); + if (driver_name_env && geteuid() == getuid()) + { + /* Don't allow setuid apps to use LIBVA_DRIVER_NAME */ + driver_name = strdup(driver_name_env); + vaStatus = VA_STATUS_SUCCESS; + va_infoMessage("User requested driver '%s'\n", driver_name); + } + else + { + vaStatus = va_getDriverName(dpy, &driver_name); + va_infoMessage("va_getDriverName() returns %d\n", vaStatus); + } - if (driver_name) - free(driver_name); - return vaStatus; + if (VA_STATUS_SUCCESS == vaStatus) + { + vaStatus = va_openDriver(dpy, driver_name); + va_infoMessage("va_openDriver() returns %d\n", vaStatus); + + *major_version = VA_MAJOR_VERSION; + *minor_version = VA_MINOR_VERSION; + } + + if (driver_name) + free(driver_name); + return vaStatus; } diff --git a/va/x11/va_x11.c b/va/x11/va_x11.c index 9f233da..7f8fbd6 100644 --- a/va/x11/va_x11.c +++ b/va/x11/va_x11.c @@ -136,19 +136,10 @@ static VAStatus va_DisplayContextGetDriverName ( ) { VAStatus vaStatus; - char *driver_name_env; if (driver_name) *driver_name = NULL; - if ((driver_name_env = getenv("LIBVA_DRIVER_NAME")) != NULL - && geteuid() == getuid()) - { - /* don't allow setuid apps to use LIBVA_DRIVER_NAME */ - *driver_name = strdup(driver_name_env); - return VA_STATUS_SUCCESS; - } - vaStatus = va_DRI2GetDriverName(pDisplayContext, driver_name); if (vaStatus != VA_STATUS_SUCCESS) vaStatus = va_DRIGetDriverName(pDisplayContext, driver_name); |