Laurent Pinchart wrote: > Hi Christopher, > > On Monday 11 February 2008, Christopher Harvey wrote: > >> Hello, >> I sent this to the video 4 linux mailing list earlier, but perhaps it's >> more appropriate here since the code is very uvc specific. >> > > Actually the bug is in your application, so it's not UVC specific :-) > Good to know! I'd rather have to deal with a broken app than a broken driver. > >> I've created a small c program that uses pure v4l2 code to read from a >> webcam on a uvc driver then copy that data into an SDL overlay. I've >> posted the code here: >> http://basementcode.com/serverMain.html >> and I've attached a log file I created from the output of that program. >> Overall the program works great except that after a few frames, about 35 >> (varies each run) in my case, the select() function that is supposed to >> block until new data from the webcam is available stops working and >> returns right away. This isn't a huge problem because the following >> ioctl(fd, VIDIOC_DQBUF, &buf) >> call simply fails and sets errno to EAGAIN, then my app simply tries >> again and again until it works. I'd rather select worked for the entire >> duration of the capture to save cpu time and make sure that I read the >> frame asap each time. The relevant function in the code I posted above >> is "mainLoop", however I can't be sure the error is actually in that >> function. I hope I've posted enough information. >> > > Your error is here: > > timeout.tv_sec = 2; > timeout.tv_usec = 0; > > for(i = 0;i<200;i++) > { > FD_ZERO(&fds); > FD_SET(fd, &fds); > > if(select(fd+1, &fds, NULL, NULL, &timeout)==-1) > { > printf("Error with select.\n"); > break; > } > > select() modifies the timeout parameter to return the remaining time. Your > application will see timeout slowly decrementing until it reaches 0. select() > will then always return immediately. > > You must reinitialise timeout in the for loop. > > Best regards, > > Laurent Pinchart > > Great, I see it now. Thank you very much for taking the time to look through my code and write up a reply.
Best regards, Chris. _______________________________________________ Linux-uvc-devel mailing list [email protected] https://lists.berlios.de/mailman/listinfo/linux-uvc-devel
