[FFmpeg-devel] [PATCH v2 3/3] hwcontext_vaapi: #if guard VAAPI_DRM specifics

Emil Velikov emil.l.velikov at gmail.com
Wed Jul 20 13:56:46 EEST 2022


From: Emil Velikov <emil.velikov at collabora.com>

Similar to the VAAPI_X11 bits, guard all the VAAPI_DRM parts behind a
compiler guard.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 libavutil/hwcontext_vaapi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 7734a50fc0..7aea3e7b96 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -18,6 +18,10 @@
 
 #include "config.h"
 
+#if !HAVE_VAAPI_X11 && !HAVE_VAAPI_DRM
+#error "At least one VAAPI winsys is required X11 or DRM"
+#endif
+
 #if CONFIG_VAAPI_1
 #   define VA_ABI ".2"
 #else
@@ -68,8 +72,10 @@ typedef struct VAAPIDevicePriv {
     Display *x11_display;
 #endif
 
+#if HAVE_VAAPI_DRM
     void *libva_drm;
     int drm_fd;
+#endif
 } VAAPIDevicePriv;
 
 typedef struct VAAPISurfaceFormat {
@@ -1583,10 +1589,12 @@ static void vaapi_device_free(AVHWDeviceContext *ctx)
         XCloseDisplay(priv->x11_display);
 #endif
 
+#if HAVE_VAAPI_DRM
     if (priv->drm_fd >= 0)
         close(priv->drm_fd);
     if (priv->libva_drm)
         dlclose(priv->libva_drm);
+#endif
 
     av_freep(&priv);
 }
@@ -1645,7 +1653,9 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
     if (!priv)
         return AVERROR(ENOMEM);
 
+#if HAVE_VAAPI_DRM
     priv->drm_fd = -1;
+#endif
 
     ctx->user_opaque = priv;
     ctx->free        = vaapi_device_free;
-- 
2.37.0



More information about the ffmpeg-devel mailing list