diff options
author | Aaron Plattner <aplattner@nvidia.com> | 2009-11-17 00:18:05 -0800 |
---|---|---|
committer | Aaron Plattner <aplattner@nvidia.com> | 2009-11-17 13:13:06 -0800 |
commit | 0537b13e292bc772e984872a3986e41fb51f9258 (patch) | |
tree | 2fef0f05e04527c7373bf557aeb8e52bad36e2d7 | |
parent | f1f2b25e39b7092a94067f1c787a9b5c5c58bb5d (diff) |
Move VDPAU drivers into their own module directory.
* Add a --with-module-dir configure parameter.
* Pass the moduledir into the wrapper. Use it to construct the path to search
for drivers. Require drivers to end in a ".1" version, in case we ever want
to rev. the interface between the wrapper and the drivers.
* If no driver is found in the new module dir, look for one in the default
search paths. This is intended to find libvdpau_nvidia.so for drivers that
predate the change to move it, and can be removed in the future.
* Stash the moduledir into vdpau.pc. Drivers can find this with
`pkg-config --variable=moduledir vdpau`.
* Add a version to libvdpau_trace.so in case the interface between it and
libvdpau.so ever changes.
* Install libvdpau_trace.so.1 to moduledir instead of libdir.
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | include/vdpau/vdpau_x11.h | 16 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/vdpau_wrapper.c | 26 | ||||
-rw-r--r-- | trace/Makefile.am | 4 | ||||
-rw-r--r-- | vdpau.pc.in | 1 |
6 files changed, 38 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac index eb78cc8..207449c 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,14 @@ fi AM_CONDITIONAL([ENABLE_DOCS], [test "x$DOXYGEN" != xno -a "x$DOT" != xno -a "x$PDFTEX" != xno]) AC_SUBST(DOXYGEN) +# Options +AC_ARG_WITH(module-dir, + AC_HELP_STRING([--with-module-dir=DIR], + [Default module directory [[default=LIBDIR/vdpau]]]), + [moduledir="$withval"], + [moduledir="$libdir/vdpau"]) +AC_SUBST(moduledir) + XORG_CHANGELOG AC_OUTPUT([Makefile diff --git a/include/vdpau/vdpau_x11.h b/include/vdpau/vdpau_x11.h index e8445f1..5fe0089 100644 --- a/include/vdpau/vdpau_x11.h +++ b/include/vdpau/vdpau_x11.h @@ -6,7 +6,7 @@ /* * This copyright notice applies to this header file: * - * Copyright (c) 2008 NVIDIA Corporation + * Copyright (c) 2008-2009 NVIDIA Corporation * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation @@ -72,13 +72,15 @@ extern "C" { * standard system (possibly X11-specific) library path. * - \c libvdpau.so.1 (runtime) * - \c libvdpau.so (development) - * - Back-end driver files. These files are located in the - * standard system (possibly X11-specific) library path. - * - \c libvdpau_\%s.so + * - Back-end driver files. These files are located in a + * system-defined library path, which is configurable at compile + * time but is typically /usr/lib/vdpau. Use `pkg-config + * --variable=moduledir vdpau` to locate the driver install path. + * - \c $moduledir/libvdpau_\%s.so.1 * For example: - * - \c libvdpau_nvidia.so - * - \c libvdpau_intel.so - * - \c libvdpau_ati.so + * - \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 VDPAU wrapper library implements just one function; \ref * vdp_device_create_x11. The wrapper will implement this function diff --git a/src/Makefile.am b/src/Makefile.am index 0bca810..923eaac 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,6 @@ AM_CFLAGS = \ -I$(top_srcdir)/include \ + -DVDPAU_MODULEDIR="\"$(moduledir)\"" \ $(X11_CFLAGS) lib_LTLIBRARIES = libvdpau.la diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c index 2687c31..a635f6c 100644 --- a/src/vdpau_wrapper.c +++ b/src/vdpau_wrapper.c @@ -22,6 +22,7 @@ */ #include <dlfcn.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -46,7 +47,7 @@ static void _vdp_wrapper_error_breakpoint(char const * file, int line, char cons #endif -#define DRIVER_LIB_FORMAT "libvdpau_%s.so" +#define DRIVER_LIB_FORMAT "%slibvdpau_%s.so%s" VdpStatus vdp_device_create_x11( Display * display, @@ -57,7 +58,7 @@ VdpStatus vdp_device_create_x11( ) { char const * vdpau_driver; - char * vdpau_driver_lib; + char vdpau_driver_lib[PATH_MAX]; void * backend_dll; char const * vdpau_trace; char const * func_name; @@ -70,15 +71,23 @@ VdpStatus vdp_device_create_x11( vdpau_driver = "nvidia"; } - vdpau_driver_lib = malloc(strlen(DRIVER_LIB_FORMAT) + strlen(vdpau_driver) + 1); - if (!vdpau_driver_lib) { + if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT, + VDPAU_MODULEDIR "/", vdpau_driver, ".1") >= + sizeof(vdpau_driver_lib)) { + fprintf(stderr, "Failed to construct driver path: path too long\n"); _VDP_ERROR_BREAKPOINT(); - return VDP_STATUS_RESOURCES; + return VDP_STATUS_NO_IMPLEMENTATION; } - sprintf(vdpau_driver_lib, DRIVER_LIB_FORMAT, vdpau_driver); backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL); - free(vdpau_driver_lib); + if (!backend_dll) { + /* Try again using the old path, which is guaranteed to fit in PATH_MAX + * if the complete path fit above. */ + snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT, + "", vdpau_driver, ""); + backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL); + } + if (!backend_dll) { fprintf(stderr, "Failed to open VDPAU backend %s\n", dlerror()); _VDP_ERROR_BREAKPOINT(); @@ -90,7 +99,7 @@ VdpStatus vdp_device_create_x11( void * trace_dll; SetDllHandle * set_dll_handle; - trace_dll = dlopen("libvdpau_trace.so", RTLD_NOW | RTLD_GLOBAL); + trace_dll = dlopen(VDPAU_MODULEDIR "/libvdpau_trace.so.1", RTLD_NOW | RTLD_GLOBAL); if (!trace_dll) { fprintf(stderr, "Failed to open VDPAU trace library %s\n", dlerror()); _VDP_ERROR_BREAKPOINT(); @@ -134,4 +143,3 @@ VdpStatus vdp_device_create_x11( get_proc_address ); } - diff --git a/trace/Makefile.am b/trace/Makefile.am index 6fd771b..d134446 100644 --- a/trace/Makefile.am +++ b/trace/Makefile.am @@ -2,7 +2,7 @@ AM_CXXFLAGS = \ -I$(top_srcdir)/include \ $(X11_CFLAGS) -lib_LTLIBRARIES = libvdpau_trace.la +module_LTLIBRARIES = libvdpau_trace.la libvdpau_trace_la_SOURCES = \ vdpau_trace.cpp @@ -10,7 +10,7 @@ libvdpau_trace_la_SOURCES = \ libvdpau_trace_la_LIBADD = \ $(DLOPEN_LIBS) -libvdpau_trace_la_LDFLAGS = -avoid-version -module -no-undefined +libvdpau_trace_la_LDFLAGS = -version-info 1:0:0 -module -no-undefined libvdpau_traceincludedir = $(includedir)/vdpau libvdpau_traceinclude_HEADERS = \ diff --git a/vdpau.pc.in b/vdpau.pc.in index 1ebf57f..e48f665 100644 --- a/vdpau.pc.in +++ b/vdpau.pc.in @@ -2,6 +2,7 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ +moduledir=@moduledir@ Name: VDPAU Description: The Video Decode and Presentation API for UNIX |