|
|
@ -857,45 +857,39 @@ static int read_frame_v4l2(CvCaptureCAM_V4L* capture) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int mainloop_v4l2(CvCaptureCAM_V4L* capture) { |
|
|
|
static int mainloop_v4l2(CvCaptureCAM_V4L* capture) { |
|
|
|
unsigned int count; |
|
|
|
for (;;) { |
|
|
|
|
|
|
|
fd_set fds; |
|
|
|
|
|
|
|
struct timeval tv; |
|
|
|
|
|
|
|
int r; |
|
|
|
|
|
|
|
|
|
|
|
count = 1; |
|
|
|
FD_ZERO (&fds); |
|
|
|
|
|
|
|
FD_SET (capture->deviceHandle, &fds); |
|
|
|
|
|
|
|
|
|
|
|
while (count-- > 0) { |
|
|
|
/* Timeout. */ |
|
|
|
for (;;) { |
|
|
|
tv.tv_sec = 10; |
|
|
|
fd_set fds; |
|
|
|
tv.tv_usec = 0; |
|
|
|
struct timeval tv; |
|
|
|
|
|
|
|
int r; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FD_ZERO (&fds); |
|
|
|
r = select (capture->deviceHandle+1, &fds, NULL, NULL, &tv); |
|
|
|
FD_SET (capture->deviceHandle, &fds); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Timeout. */ |
|
|
|
if (-1 == r) { |
|
|
|
tv.tv_sec = 10; |
|
|
|
if (EINTR == errno) |
|
|
|
tv.tv_usec = 0; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
r = select (capture->deviceHandle+1, &fds, NULL, NULL, &tv); |
|
|
|
perror ("select"); |
|
|
|
|
|
|
|
} |
|
|
|
if (-1 == r) { |
|
|
|
|
|
|
|
if (EINTR == errno) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
perror ("select"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 == r) { |
|
|
|
if (0 == r) { |
|
|
|
fprintf (stderr, "select timeout\n"); |
|
|
|
fprintf (stderr, "select timeout\n"); |
|
|
|
|
|
|
|
|
|
|
|
/* end the infinite loop */ |
|
|
|
/* end the infinite loop */ |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int returnCode = read_frame_v4l2 (capture); |
|
|
|
|
|
|
|
if(returnCode == -1) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
if(returnCode == 1) |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int returnCode = read_frame_v4l2 (capture); |
|
|
|
|
|
|
|
if(returnCode == -1) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
if(returnCode == 1) |
|
|
|
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|