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>
stable
Damjan Jovanovic 2019-04-23 03:15:16 +02:00 committed by Alexandre Julliard
parent 2e9a036f9a
commit 862566a2b0
1 changed files with 10 additions and 3 deletions

View File

@ -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)