From: Andreas Kies <andikies@web.de> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH] improve VAAPI error handling Date: Sat, 10 Sep 2022 19:12:59 +0200 Message-ID: <91efc26f-85a3-ceaa-c5ad-a2e23659c60f@web.de> (raw) [-- Attachment #1: Type: text/plain, Size: 361 bytes --] In case something is wrong in vaapi_device_create() you usually just get EINVAL, but not the real cause. This patch allows to return the cause as set in errno. EINVAL is used for kernel driver name mismatch. ENODEV in case vaGetDisplayDRM() fails. Also changed: Try X11 interface in case vaGetDisplayDRM() fails. Try to open any of the possible 8 devices. [-- Attachment #2: 0001-improve-VAAPI-error-handling.patch --] [-- Type: text/x-patch, Size: 3354 bytes --] From 09c11ebba68076c5c17254ea42183e6031a9a44f Mon Sep 17 00:00:00 2001 From: Andik <andik@localhost> Date: Sat, 10 Sep 2022 18:22:03 +0200 Subject: [PATCH] improve VAAPI error handling --- libavutil/hwcontext_vaapi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 9ba5225ad2..82218c4c9c 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1655,6 +1655,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, VADisplay display = NULL; const AVDictionaryEntry *ent; int try_drm, try_x11, try_all; + int dev_errno = ENOENT; priv = av_mallocz(sizeof(*priv)); if (!priv) @@ -1692,6 +1693,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, if (device) { priv->drm_fd = open(device, O_RDWR); if (priv->drm_fd < 0) { + dev_errno = errno; av_log(ctx, loglevel, "Failed to open %s as " "DRM device node.\n", device); break; @@ -1708,15 +1710,18 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, "/dev/dri/renderD%d", 128 + n); priv->drm_fd = open(path, O_RDWR); if (priv->drm_fd < 0) { + if (errno != ENOENT) + dev_errno = errno; av_log(ctx, AV_LOG_VERBOSE, "Cannot open " "DRM render node for device %d.\n", n); - break; + continue; } #if CONFIG_LIBDRM if (kernel_driver) { drmVersion *info; info = drmGetVersion(priv->drm_fd); if (strcmp(kernel_driver->value, info->name)) { + dev_errno = EINVAL; av_log(ctx, AV_LOG_VERBOSE, "Ignoring device %d " "with non-matching kernel driver (%s).\n", n, info->name); @@ -1744,9 +1749,9 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, display = vaGetDisplayDRM(priv->drm_fd); if (!display) { + dev_errno = ENODEV; av_log(ctx, AV_LOG_VERBOSE, "Cannot open a VA display " "from DRM device %s.\n", device); - return AVERROR_EXTERNAL; } break; } @@ -1757,6 +1762,8 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, // Try to open the device as an X11 display. priv->x11_display = XOpenDisplay(device); if (!priv->x11_display) { + if (errno != ENOENT) + dev_errno = errno; av_log(ctx, AV_LOG_VERBOSE, "Cannot open X11 display " "%s.\n", XDisplayName(device)); } else { @@ -1780,7 +1787,7 @@ static int vaapi_device_create(AVHWDeviceContext *ctx, const char *device, else av_log(ctx, AV_LOG_ERROR, "No VA display found for " "any default device.\n"); - return AVERROR(EINVAL); + return AVERROR(dev_errno); } ent = av_dict_get(opts, "driver", NULL, 0); -- 2.34.1 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2022-09-10 17:13 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-10 17:12 Andreas Kies [this message] 2022-09-19 4:08 ` Xiang, Haihao
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=91efc26f-85a3-ceaa-c5ad-a2e23659c60f@web.de \ --to=andikies@web.de \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git