summaryrefslogtreecommitdiff
path: root/uvc-gadget.c
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2018-05-21 23:45:17 +0800
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2018-05-21 21:27:39 +0300
commit349679083d1f1053ee79cc933e0e41c48ce05fb9 (patch)
treeb38a26dd0023624de0f4beea56d6fcf627d15900 /uvc-gadget.c
parent702526917b38d832788fd737ff9e6d5fa8f83fc5 (diff)
uvc-gadget: Dynamically watch/unwatch uvc device fd
When the uvc device fd is put on the watch list statically, then there are many "Unable to dequeue buffer: Invalid argument (22)." because the V4L2 API returns write events immediately when the stream is off. To fix this, add the fd to the watch list on streamon, and remove it on streamoff. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'uvc-gadget.c')
-rw-r--r--uvc-gadget.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/uvc-gadget.c b/uvc-gadget.c
index 31dbbf6..7d6c20a 100644
--- a/uvc-gadget.c
+++ b/uvc-gadget.c
@@ -251,6 +251,7 @@ uvc_video_stream(struct uvc_device *dev, int enable)
if (!enable) {
printf("Stopping video stream.\n");
+ events_unwatch_fd(&dev->events, dev->fd, EVENT_WRITE);
ioctl(dev->fd, VIDIOC_STREAMOFF, &type);
return 0;
}
@@ -275,6 +276,8 @@ uvc_video_stream(struct uvc_device *dev, int enable)
}
ioctl(dev->fd, VIDIOC_STREAMON, &type);
+ events_watch_fd(&dev->events, dev->fd, EVENT_WRITE,
+ uvc_video_process, dev);
return ret;
}
@@ -749,8 +752,6 @@ int main(int argc, char *argv[])
uvc_device = dev;
signal(SIGINT, sigint_handler);
- events_watch_fd(&dev->events, dev->fd, EVENT_WRITE,
- uvc_video_process, dev);
events_watch_fd(&dev->events, dev->fd, EVENT_EXCEPTION,
uvc_events_process, dev);