From 545bf1d043af1e79650666f5785cf6e7d413c4e7 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Mon, 21 May 2018 23:45:15 +0800 Subject: events: Remove select timeout The reason why no timeout is needed is twofold: When the stream is off extensive periods of time can pass without an event occurring if the host doesn't send any UVC request. As that period of time is unbound, we can't set any meaningful timeout. When the stream is on buffers are supposed to flow constantly. If buffers stop flowing that would indicate a bug somewhere in the stack, which could be caught by a timeout, but that we wouldn't be able to recover from anyway. The timeout is thus not needed and harmful when the stream is off. Remove it. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart --- events.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/events.c b/events.c index cc6c6cd..6840c19 100644 --- a/events.c +++ b/events.c @@ -128,19 +128,16 @@ bool events_loop(struct events *events) events->done = false; while (!events->done) { - struct timeval timeout; fd_set rfds; fd_set wfds; fd_set efds; int ret; - timeout.tv_sec = SELECT_TIMEOUT / 1000; - timeout.tv_usec = (SELECT_TIMEOUT % 1000) * 1000; rfds = events->rfds; wfds = events->wfds; efds = events->efds; - ret = select(events->maxfd + 1, &rfds, &wfds, &efds, &timeout); + ret = select(events->maxfd + 1, &rfds, &wfds, &efds, NULL); if (ret < 0) { /* EINTR means that a signal has been received, continue * to the next iteration in that case. @@ -151,14 +148,6 @@ bool events_loop(struct events *events) printf("error: select failed with %d\n", errno); break; } - if (ret == 0) { - /* select() should never time out as the ISP is supposed - * to capture images continuously. A timeout is thus - * considered as a fatal error. - */ - printf("error: select timeout\n"); - break; - } events_dispatch(events, &rfds, &wfds, &efds); } -- cgit v1.2.3