From 48a7c4be3a8ea97ddc2150c20b5cf4db4f1b8e85 Mon Sep 17 00:00:00 2001 From: Philip Langdale Date: Thu, 24 Nov 2016 11:07:21 -0800 Subject: vo_opengl: hwdec_cuda: Prefix cuda symbols to avoid collisions We want to avoid causing problems if libmpv is used in an application that links cuda, or if the libav* libraries are linked with cuda, as might happen if the scale_npp filter is used. --- video/out/opengl/cuda_dynamic.c | 6 +++--- video/out/opengl/cuda_dynamic.h | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/video/out/opengl/cuda_dynamic.c b/video/out/opengl/cuda_dynamic.c index f37baca6d0..1135a1f077 100644 --- a/video/out/opengl/cuda_dynamic.c +++ b/video/out/opengl/cuda_dynamic.c @@ -22,7 +22,7 @@ #if defined(_WIN32) # include # define dlopen(filename, flags) LoadLibrary(TEXT(filename)) -# define dlsym(handle, symbol) GetProcAddress(handle, symbol) +# define dlsym(handle, symbol) (void *)GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #else # include @@ -35,7 +35,7 @@ #endif #define CUDA_DECL(NAME, TYPE) \ - TYPE *NAME; + TYPE *mpv_ ## NAME; CUDA_FNS(CUDA_DECL) static bool cuda_loaded = false; @@ -49,7 +49,7 @@ static void cuda_do_load(void) } #define CUDA_LOAD_SYMBOL(NAME, TYPE) \ - NAME = (TYPE *)dlsym(lib, #NAME); if (!NAME) return; + mpv_ ## NAME = dlsym(lib, #NAME); if (!mpv_ ## NAME) return; CUDA_FNS(CUDA_LOAD_SYMBOL) diff --git a/video/out/opengl/cuda_dynamic.h b/video/out/opengl/cuda_dynamic.h index bdac626be5..ecf212aa82 100644 --- a/video/out/opengl/cuda_dynamic.h +++ b/video/out/opengl/cuda_dynamic.h @@ -119,20 +119,27 @@ typedef CUresult CUDAAPI tcuGraphicsSubResourceGetMappedArray(CUarray* pArray, C FN(cuGraphicsUnregisterResource, tcuGraphicsUnregisterResource) \ FN(cuGraphicsMapResources, tcuGraphicsMapResources) \ FN(cuGraphicsUnmapResources, tcuGraphicsUnmapResources) \ - FN(cuGraphicsUnmapResources, tcuGraphicsUnmapResources) \ FN(cuGraphicsSubResourceGetMappedArray, tcuGraphicsSubResourceGetMappedArray) \ #define CUDA_EXT_DECL(NAME, TYPE) \ - extern TYPE *NAME; + extern TYPE *mpv_ ## NAME; CUDA_FNS(CUDA_EXT_DECL) -#define cuCtxCreate cuCtxCreate_v2 -#define cuCtxPushCurrent cuCtxPushCurrent_v2 -#define cuCtxPopCurrent cuCtxPopCurrent_v2 -#define cuCtxDestroy cuCtxDestroy_v2 -#define cuMemcpy2D cuMemcpy2D_v2 -#define cuGLGetDevices cuGLGetDevices_v2 +#define cuInit mpv_cuInit +#define cuCtxCreate mpv_cuCtxCreate_v2 +#define cuCtxPushCurrent mpv_cuCtxPushCurrent_v2 +#define cuCtxPopCurrent mpv_cuCtxPopCurrent_v2 +#define cuCtxDestroy mpv_cuCtxDestroy_v2 +#define cuMemcpy2D mpv_cuMemcpy2D_v2 +#define cuGetErrorName mpv_cuGetErrorName +#define cuGetErrorString mpv_cuGetErrorString +#define cuGLGetDevices mpv_cuGLGetDevices_v2 +#define cuGraphicsGLRegisterImage mpv_cuGraphicsGLRegisterImage +#define cuGraphicsUnregisterResource mpv_cuGraphicsUnregisterResource +#define cuGraphicsMapResources mpv_cuGraphicsMapResources +#define cuGraphicsUnmapResources mpv_cuGraphicsUnmapResources +#define cuGraphicsSubResourceGetMappedArray mpv_cuGraphicsSubResourceGetMappedArray bool cuda_load(void); -- cgit v1.2.3