[FFmpeg-cvslog] hwcontext_vaapi: Try the first render node as the default DRM device

Mark Thompson git at videolan.org
Sat Mar 18 21:02:31 EET 2017


ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Thu Jul 28 23:28:30 2016 +0100| [121f34d5f0c8d7d376829a467590fbbe4c228f4f] | committer: Mark Thompson

hwcontext_vaapi: Try the first render node as the default DRM device

If no string argument is supplied when av_hwdevice_ctx_create() is
called to create a VAAPI device, we currently only try the default
X11 display (that is, $DISPLAY) to find a device, and will therefore
fail in the absence of an X server to connect to.  Change the logic
to also look for a device via the first DRM render node (that is,
"/dev/dri/renderD128"), which is probably the right thing to use in
most simple configurations which only have one DRM device.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=121f34d5f0c8d7d376829a467590fbbe4c228f4f
---

 libavutil/hwcontext_vaapi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index 506545c..bba0c4d 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -924,22 +924,25 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
 #endif
 
 #if HAVE_VAAPI_DRM
-    if (!display && device) {
+    if (!display) {
         // Try to open the device as a DRM path.
-        priv->drm_fd = open(device, O_RDWR);
+        // Default to using the first render node if the user did not
+        // supply a path.
+        const char *path = device ? device : "/dev/dri/renderD128";
+        priv->drm_fd = open(path, O_RDWR);
         if (priv->drm_fd < 0) {
             av_log(ctx, AV_LOG_VERBOSE, "Cannot open DRM device %s.\n",
-                   device);
+                   path);
         } else {
             display = vaGetDisplayDRM(priv->drm_fd);
             if (!display) {
                 av_log(ctx, AV_LOG_ERROR, "Cannot open a VA display "
-                       "from DRM device %s.\n", device);
+                       "from DRM device %s.\n", path);
                 return AVERROR_UNKNOWN;
             }
 
             av_log(ctx, AV_LOG_VERBOSE, "Opened VA display via "
-                   "DRM device %s.\n", device);
+                   "DRM device %s.\n", path);
         }
     }
 #endif



More information about the ffmpeg-cvslog mailing list