Module: wine Branch: master Commit: 862566a2b0ea1f5fe8181aa20f595dc40178081f URL: https://source.winehq.org/git/wine.git/?a=commit;h=862566a2b0ea1f5fe8181aa20...
Author: Damjan Jovanovic damjan.jov@gmail.com Date: Tue Apr 23 03:15:16 2019 +0200
avicap32: Verify v4l devices can capture before returning them.
/dev/video* device nodes aren't all capture devices, and returning those that aren't results in devenum reporting them to applications, which will later fail when opening them with IMoniker::BindToObject().
avicap32 already tries to call VIDIOC_QUERYCAP to check whether it's dealing with a v4l device, but it does not check a successful result any further. Get it to verify the device supports the V4L2_CAP_VIDEO_CAPTURE flag, like we do in qcap/v4l.c.
Signed-off-by: Damjan Jovanovic damjan.jov@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/avicap32/avicap32_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/avicap32/avicap32_main.c b/dlls/avicap32/avicap32_main.c index 445656c..1c4170e 100644 --- a/dlls/avicap32/avicap32_main.c +++ b/dlls/avicap32/avicap32_main.c @@ -128,11 +128,18 @@ static BOOL query_video_device(int devnum, char *name, int namesize, char *versi
memset(&caps, 0, sizeof(caps)); if (xioctl(fd, VIDIOC_QUERYCAP, &caps) != -1) { - lstrcpynA(name, (char *)caps.card, namesize); - snprintf(version, versionsize, "%s v%u.%u.%u", (char *)caps.driver, (caps.version >> 16) & 0xFF, + BOOL isCaptureDevice; + if (caps.capabilities & V4L2_CAP_DEVICE_CAPS) + isCaptureDevice = caps.device_caps & V4L2_CAP_VIDEO_CAPTURE; + else + isCaptureDevice = caps.capabilities & V4L2_CAP_VIDEO_CAPTURE; + if (isCaptureDevice) { + lstrcpynA(name, (char *)caps.card, namesize); + snprintf(version, versionsize, "%s v%u.%u.%u", (char *)caps.driver, (caps.version >> 16) & 0xFF, (caps.version >> 8) & 0xFF, caps.version & 0xFF); + } close(fd); - return TRUE; + return isCaptureDevice; }
if (errno != EINVAL && errno != 515)