From 46da27966fefda91510002ea939d6e901c86f1d7 Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Tue, 29 Jul 2008 21:48:08 +0200 Subject: libv4l2: work around wrong REQUEST_BUFFERS ioctl return code From: Gregor Jasny libv4l2: work around wrong REQUEST_BUFFERS ioctl return code Signed-off-by: Gregor Jasny Signed-off-by: Hans de Goede Acked-by: Mauro Carvalho Chehab --- v4l2-apps/lib/libv4l/libv4l2/libv4l2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'v4l2-apps/lib/libv4l/libv4l2/libv4l2.c') diff --git a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c index 8dfcf9b71..b2ab4dede 100644 --- a/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c +++ b/v4l2-apps/lib/libv4l/libv4l2/libv4l2.c @@ -97,7 +97,7 @@ static int v4l2_request_read_buffers(int index) req.count = devices[index].nreadbuffers; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.memory = V4L2_MEMORY_MMAP; - if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, &req))){ + if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, &req)) < 0){ int saved_err = errno; V4L2_LOG_ERR("requesting buffers: %s\n", strerror(errno)); errno = saved_err; @@ -121,7 +121,7 @@ static int v4l2_unrequest_read_buffers(int index) req.count = 0; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.memory = V4L2_MEMORY_MMAP; - if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, &req))) { + if ((result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, &req)) < 0) { int saved_err = errno; V4L2_LOG_ERR("unrequesting buffers: %s\n", strerror(errno)); errno = saved_err; @@ -723,8 +723,9 @@ int v4l2_ioctl (int fd, unsigned long int request, ...) v4l2_unmap_buffers(index); result = syscall(SYS_ioctl, devices[index].fd, VIDIOC_REQBUFS, req); - if (result) + if (result < 0) break; + result = 0; // some drivers return the number of buffers on success /* If we got more frames then we can handle lie to the app */ if (req->count > V4L2_MAX_NO_FRAMES) -- cgit v1.2.3