|
Lines 40-45
typedef void SetDllHandle(
Link Here
|
| 40 |
void * driver_dll_handle |
40 |
void * driver_dll_handle |
| 41 |
); |
41 |
); |
| 42 |
|
42 |
|
|
|
43 |
static void * _vdp_backend_dll; |
| 44 |
static void * _vdp_trace_dll; |
| 45 |
static void * _vdp_driver_dll; |
| 46 |
static VdpDeviceCreateX11 * _vdp_imp_device_create_x11_proc; |
| 47 |
|
| 48 |
#if defined(__GNUC__) |
| 49 |
|
| 50 |
static void _vdp_close_driver(void) __attribute__((destructor)); |
| 51 |
|
| 52 |
#endif |
| 53 |
|
| 43 |
#if DEBUG |
54 |
#if DEBUG |
| 44 |
|
55 |
|
| 45 |
static void _vdp_wrapper_error_breakpoint(char const * file, int line, char const * function) |
56 |
static void _vdp_wrapper_error_breakpoint(char const * file, int line, char const * function) |
|
Lines 87-109
static char * _vdp_get_driver_name_from_dri2(
Link Here
|
| 87 |
return driver_name; |
98 |
return driver_name; |
| 88 |
} |
99 |
} |
| 89 |
|
100 |
|
| 90 |
VdpStatus vdp_device_create_x11( |
101 |
static VdpStatus _vdp_open_driver( |
| 91 |
Display * display, |
102 |
Display * display, |
| 92 |
int screen, |
103 |
int screen) |
| 93 |
/* output parameters follow */ |
|
|
| 94 |
VdpDevice * device, |
| 95 |
VdpGetProcAddress * * get_proc_address |
| 96 |
) |
| 97 |
{ |
104 |
{ |
| 98 |
char const * vdpau_driver; |
105 |
char const * vdpau_driver; |
| 99 |
char * vdpau_driver_dri2 = NULL; |
106 |
char * vdpau_driver_dri2 = NULL; |
| 100 |
char vdpau_driver_lib[PATH_MAX]; |
107 |
char vdpau_driver_lib[PATH_MAX]; |
| 101 |
void * backend_dll; |
|
|
| 102 |
char const * vdpau_trace; |
108 |
char const * vdpau_trace; |
| 103 |
char const * func_name; |
109 |
char const * func_name; |
| 104 |
|
110 |
|
| 105 |
VdpDeviceCreateX11 * vdp_imp_device_create_x11; |
|
|
| 106 |
|
| 107 |
vdpau_driver = getenv("VDPAU_DRIVER"); |
111 |
vdpau_driver = getenv("VDPAU_DRIVER"); |
| 108 |
if (!vdpau_driver) { |
112 |
if (!vdpau_driver) { |
| 109 |
vdpau_driver = vdpau_driver_dri2 = |
113 |
vdpau_driver = vdpau_driver_dri2 = |
|
Lines 125-137
VdpStatus vdp_device_create_x11(
Link Here
|
| 125 |
return VDP_STATUS_NO_IMPLEMENTATION; |
129 |
return VDP_STATUS_NO_IMPLEMENTATION; |
| 126 |
} |
130 |
} |
| 127 |
|
131 |
|
| 128 |
backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL); |
132 |
_vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL); |
| 129 |
if (!backend_dll) { |
133 |
if (!_vdp_driver_dll) { |
| 130 |
/* Try again using the old path, which is guaranteed to fit in PATH_MAX |
134 |
/* Try again using the old path, which is guaranteed to fit in PATH_MAX |
| 131 |
* if the complete path fit above. */ |
135 |
* if the complete path fit above. */ |
| 132 |
snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT, |
136 |
snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT, |
| 133 |
"", vdpau_driver, ""); |
137 |
"", vdpau_driver, ""); |
| 134 |
backend_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL); |
138 |
_vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL); |
| 135 |
} |
139 |
} |
| 136 |
|
140 |
|
| 137 |
if (vdpau_driver_dri2) { |
141 |
if (vdpau_driver_dri2) { |
|
Lines 139-164
VdpStatus vdp_device_create_x11(
Link Here
|
| 139 |
vdpau_driver_dri2 = NULL; |
143 |
vdpau_driver_dri2 = NULL; |
| 140 |
} |
144 |
} |
| 141 |
|
145 |
|
| 142 |
if (!backend_dll) { |
146 |
if (!_vdp_driver_dll) { |
| 143 |
fprintf(stderr, "Failed to open VDPAU backend %s\n", dlerror()); |
147 |
fprintf(stderr, "Failed to open VDPAU backend %s\n", dlerror()); |
| 144 |
_VDP_ERROR_BREAKPOINT(); |
148 |
_VDP_ERROR_BREAKPOINT(); |
| 145 |
return VDP_STATUS_NO_IMPLEMENTATION; |
149 |
return VDP_STATUS_NO_IMPLEMENTATION; |
| 146 |
} |
150 |
} |
| 147 |
|
151 |
|
|
|
152 |
_vdp_backend_dll = _vdp_driver_dll; |
| 153 |
|
| 148 |
vdpau_trace = getenv("VDPAU_TRACE"); |
154 |
vdpau_trace = getenv("VDPAU_TRACE"); |
| 149 |
if (vdpau_trace && atoi(vdpau_trace)) { |
155 |
if (vdpau_trace && atoi(vdpau_trace)) { |
| 150 |
void * trace_dll; |
|
|
| 151 |
SetDllHandle * set_dll_handle; |
156 |
SetDllHandle * set_dll_handle; |
| 152 |
|
157 |
|
| 153 |
trace_dll = dlopen(VDPAU_MODULEDIR "/libvdpau_trace.so.1", RTLD_NOW | RTLD_GLOBAL); |
158 |
_vdp_trace_dll = dlopen(VDPAU_MODULEDIR "/libvdpau_trace.so.1", |
| 154 |
if (!trace_dll) { |
159 |
RTLD_NOW | RTLD_GLOBAL); |
|
|
160 |
if (!_vdp_trace_dll) { |
| 155 |
fprintf(stderr, "Failed to open VDPAU trace library %s\n", dlerror()); |
161 |
fprintf(stderr, "Failed to open VDPAU trace library %s\n", dlerror()); |
| 156 |
_VDP_ERROR_BREAKPOINT(); |
162 |
_VDP_ERROR_BREAKPOINT(); |
| 157 |
return VDP_STATUS_NO_IMPLEMENTATION; |
163 |
return VDP_STATUS_NO_IMPLEMENTATION; |
| 158 |
} |
164 |
} |
| 159 |
|
165 |
|
| 160 |
set_dll_handle = (SetDllHandle*)dlsym( |
166 |
set_dll_handle = (SetDllHandle*)dlsym( |
| 161 |
trace_dll, |
167 |
_vdp_trace_dll, |
| 162 |
"vdp_trace_set_backend_handle" |
168 |
"vdp_trace_set_backend_handle" |
| 163 |
); |
169 |
); |
| 164 |
if (!set_dll_handle) { |
170 |
if (!set_dll_handle) { |
|
Lines 167-175
VdpStatus vdp_device_create_x11(
Link Here
|
| 167 |
return VDP_STATUS_NO_IMPLEMENTATION; |
173 |
return VDP_STATUS_NO_IMPLEMENTATION; |
| 168 |
} |
174 |
} |
| 169 |
|
175 |
|
| 170 |
set_dll_handle(backend_dll); |
176 |
set_dll_handle(_vdp_backend_dll); |
| 171 |
|
177 |
|
| 172 |
backend_dll = trace_dll; |
178 |
_vdp_backend_dll = _vdp_trace_dll; |
| 173 |
|
179 |
|
| 174 |
func_name = "vdp_trace_device_create_x11"; |
180 |
func_name = "vdp_trace_device_create_x11"; |
| 175 |
} |
181 |
} |
|
Lines 177-193
VdpStatus vdp_device_create_x11(
Link Here
|
| 177 |
func_name = "vdp_imp_device_create_x11"; |
183 |
func_name = "vdp_imp_device_create_x11"; |
| 178 |
} |
184 |
} |
| 179 |
|
185 |
|
| 180 |
vdp_imp_device_create_x11 = (VdpDeviceCreateX11*)dlsym( |
186 |
_vdp_imp_device_create_x11_proc = (VdpDeviceCreateX11*)dlsym( |
| 181 |
backend_dll, |
187 |
_vdp_backend_dll, |
| 182 |
func_name |
188 |
func_name |
| 183 |
); |
189 |
); |
| 184 |
if (!vdp_imp_device_create_x11) { |
190 |
if (!_vdp_imp_device_create_x11_proc) { |
| 185 |
fprintf(stderr, "%s\n", dlerror()); |
191 |
fprintf(stderr, "%s\n", dlerror()); |
| 186 |
_VDP_ERROR_BREAKPOINT(); |
192 |
_VDP_ERROR_BREAKPOINT(); |
| 187 |
return VDP_STATUS_NO_IMPLEMENTATION; |
193 |
return VDP_STATUS_NO_IMPLEMENTATION; |
| 188 |
} |
194 |
} |
| 189 |
|
195 |
|
| 190 |
return vdp_imp_device_create_x11( |
196 |
return VDP_STATUS_OK; |
|
|
197 |
} |
| 198 |
|
| 199 |
static void _vdp_close_driver(void) |
| 200 |
{ |
| 201 |
if (_vdp_driver_dll) { |
| 202 |
dlclose(_vdp_driver_dll); |
| 203 |
_vdp_driver_dll = NULL; |
| 204 |
} |
| 205 |
if (_vdp_trace_dll) { |
| 206 |
dlclose(_vdp_trace_dll); |
| 207 |
_vdp_trace_dll = NULL; |
| 208 |
} |
| 209 |
_vdp_backend_dll = NULL; |
| 210 |
_vdp_imp_device_create_x11_proc = NULL; |
| 211 |
} |
| 212 |
|
| 213 |
VdpStatus vdp_device_create_x11( |
| 214 |
Display * display, |
| 215 |
int screen, |
| 216 |
/* output parameters follow */ |
| 217 |
VdpDevice * device, |
| 218 |
VdpGetProcAddress * * get_proc_address |
| 219 |
) |
| 220 |
{ |
| 221 |
VdpStatus status; |
| 222 |
|
| 223 |
if (!_vdp_imp_device_create_x11_proc) { |
| 224 |
status = _vdp_open_driver(display, screen); |
| 225 |
if (status != VDP_STATUS_OK) { |
| 226 |
_vdp_close_driver(); |
| 227 |
return status; |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
return _vdp_imp_device_create_x11_proc( |
| 191 |
display, |
232 |
display, |
| 192 |
screen, |
233 |
screen, |
| 193 |
device, |
234 |
device, |
| 194 |
- |
|
|