struct timeval tv_s, tv_e; int delay;
struct timeval tv_s;
static int v4l_mm_read_picture(VideoData *s, UINT8 *buf){    UINT8 *ptr;    struct timeval tv_s, tv_e;    int delay;    /* Setup to capture the next frame */    gb_buf.frame = (gb_frame + 1) % gb_buffers.frames;    if (ioctl(s->fd, VIDIOCMCAPTURE, &gb_buf) < 0) {	if (errno == EAGAIN)	    fprintf(stderr,"Cannot Sync\n");	else            perror("VIDIOCMCAPTURE");	return -EIO;    }    gettimeofday(&tv_s, 0);    while (ioctl(s->fd, VIDIOCSYNC, &gb_frame) < 0 &&           (errno == EAGAIN || errno == EINTR));    /*    gettimeofday(&tv_e, 0);    delay = (tv_e.tv_sec - tv_s.tv_sec) * 1000000 + tv_e.tv_usec - tv_s.tv_usec;    if (delay > 10000)         printf("VIDIOCSYNC took %d us\n", delay);    */    ptr = video_buf + gb_buffers.offsets[gb_frame];    memcpy(buf, ptr, s->frame_size);    /* This is now the grabbing frame */    gb_frame = gb_buf.frame;    return s->frame_size;}