void (*_vaCreateSurfaces)(void);
// for VAAPI version >= 0.34
+#if VA_CHECK_VERSION(0, 34, 0)
typedef VAStatus (*_vaCreateSurfaces8)(VADisplay, unsigned int, unsigned int, unsigned int, VASurfaceID *,
unsigned int, VASurfaceAttrib *, unsigned int);
+#endif
// for VAAPI version < 0.34
typedef VAStatus (*_vaCreateSurfaces6)(VADisplay, int, int, int, int, VASurfaceID *);
VAStatus (*_vaDestroySurfaces)(VADisplay, VASurfaceID *, int);
static bool probe(void)
{
- void *handle = dlopen("libva-x11.so", RTLD_NOW);
- if (!handle) {
- goto error;
- }
-
- DLSYM(vaGetDisplay);
-
- handle = dlopen("libva.so", RTLD_NOW);
+ // "libva-x11.so.1" on some Ubuntu version missed dependency
+ // to "libva.so.1". To avoid "undefined symbol" error,
+ // we should use "RTLD_GLOBAL" flag.
+ void *handle = dlopen("libva.so.1", RTLD_NOW | RTLD_GLOBAL);
if (!handle) {
goto error;
}
DLSYM(vaMapBuffer);
DLSYM(vaUnmapBuffer);
+ handle = dlopen("libva-x11.so.1", RTLD_NOW);
+ if (!handle) {
+ goto error;
+ }
+
+ DLSYM(vaGetDisplay);
+
// we initialize vaapi now for sure...
if (!initialize()) {
printf("Can not initialize VA-API\n");
/* Create surfaces */
if (check_version(0, 34)) {
+#if VA_CHECK_VERSION(0, 34, 0)
if (((_vaCreateSurfaces8)_vaCreateSurfaces)(va_ctx->display, VA_RT_FORMAT_YUV420, width, height,
va_ctx->surface_id, va_ctx->surface_count, NULL, 0)) {
goto error;
}
+#else
+ printf("Can not run with VA-API version (%d, %d)\n", va_major_version, va_minor_version);
+ goto error;
+#endif
} else {
if (((_vaCreateSurfaces6)_vaCreateSurfaces)(va_ctx->display, width, height, VA_RT_FORMAT_YUV420,
va_ctx->surface_count, va_ctx->surface_id)) {