[VDPAU] [PATCH 2/2] Add VDPAU_DRIVER_PATH support
Aaron Plattner
aplattner at nvidia.com
Wed Jan 22 08:54:55 PST 2014
On 01/17/2014 11:12 AM, Emil Velikov wrote:
> Allow the user to specify the location of the backend driver,
> via the VDPAU_DRIVER_PATH environment variable. This allows
> easier testing of VDPAU backends without the need to rebuild
> libvdpau.
>
> Inspired by LIBGL_DRIVERS_PATH from mesa.
>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
> include/vdpau/vdpau_x11.h | 2 ++
> src/vdpau_wrapper.c | 13 +++++++++++--
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/include/vdpau/vdpau_x11.h b/include/vdpau/vdpau_x11.h
> index ae5a377..1aa66fe 100644
> --- a/include/vdpau/vdpau_x11.h
> +++ b/include/vdpau/vdpau_x11.h
> @@ -81,6 +81,8 @@ extern "C" {
> * - \c /usr/lib/vdpau/libvdpau_nvidia.so.1
> * - \c /usr/lib/vdpau/libvdpau_intel.so.1
> * - \c /usr/lib/vdpau/libvdpau_ati.so.1
> + * The library path can be overridden by the VDPAU_DRIVER_PATH
> + * environment variable.
> *
> * The VDPAU wrapper library implements just one function; \ref
> * vdp_device_create_x11. The wrapper will implement this function
> diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
> index 9932937..e5321b3 100644
> --- a/src/vdpau_wrapper.c
> +++ b/src/vdpau_wrapper.c
> @@ -66,7 +66,7 @@ static void _vdp_wrapper_error_breakpoint(char const * file, int line, char cons
>
> #endif
>
> -#define DRIVER_LIB_FORMAT "%slibvdpau_%s.so%s"
> +#define DRIVER_LIB_FORMAT "%s/libvdpau_%s.so%s"
>
> static char * _vdp_get_driver_name_from_dri2(
> Display * display,
> @@ -107,6 +107,7 @@ static VdpStatus _vdp_open_driver(
> {
> char const * vdpau_driver;
> char * vdpau_driver_dri2 = NULL;
> + char * vdpau_driver_path = NULL;
This should probably be a const char *.
> char vdpau_driver_lib[PATH_MAX];
> char const * vdpau_trace;
> char const * func_name;
> @@ -120,8 +121,16 @@ static VdpStatus _vdp_open_driver(
> vdpau_driver = "nvidia";
> }
>
> + if (geteuid() == getuid()) {
vdpau_wrapper.c: In function '_vdp_open_driver':
vdpau_wrapper.c:124:5: warning: implicit declaration of function 'geteuid' [-Wimplicit-function-declaration]
> + /* don't allow setuid apps to use VDPAU_DRIVER_PATH */
> + vdpau_driver_path = getenv("VDPAU_DRIVER_PATH");
> + }
> +
> + if (!vdpau_driver_path)
> + vdpau_driver_path = VDPAU_MODULEDIR;
> +
> if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT,
> - VDPAU_MODULEDIR "/", vdpau_driver, ".1") >=
> + vdpau_driver_path, vdpau_driver, ".1") >=
> sizeof(vdpau_driver_lib)) {
> fprintf(stderr, "Failed to construct driver path: path too long\n");
> if (vdpau_driver_dri2) {
Should vdpau_driver_path be used to try to find the trace library too?
--
Aaron
More information about the VDPAU
mailing list