* [FFmpeg-devel] [PATCH] improve VAAPI error handling
@ 2022-09-10 17:12 Andreas Kies
2022-09-19 4:08 ` Xiang, Haihao
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Kies @ 2022-09-10 17:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- 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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] improve VAAPI error handling
2022-09-10 17:12 [FFmpeg-devel] [PATCH] improve VAAPI error handling Andreas Kies
@ 2022-09-19 4:08 ` Xiang, Haihao
0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2022-09-19 4:08 UTC (permalink / raw)
To: ffmpeg-devel
> 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.
Could you update your commit message ? There is a warning in patchwork check
(See
https://patchwork.ffmpeg.org/project/ffmpeg/patch/91efc26f-85a3-ceaa-c5ad-a2e23659c60f@web.de/
)
BTW you may add the above message in the commit message too.
BRs
Haihao
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-19 4:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-10 17:12 [FFmpeg-devel] [PATCH] improve VAAPI error handling Andreas Kies
2022-09-19 4:08 ` Xiang, Haihao
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