From 14ded65303fbd8bc76400ce13b0282b3a43dbcfe Mon Sep 17 00:00:00 2001 From: tonton th Date: Sat, 26 Dec 2020 18:37:04 +0100 Subject: [PATCH] V4L2 : heisenbug spotted around VIDIOC_DQBUF, infinite loop --- v4l2/grabvidseq.c | 29 +++++++---------------------- v4l2/notes.txt | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 v4l2/notes.txt diff --git a/v4l2/grabvidseq.c b/v4l2/grabvidseq.c index b120711b..0649aed9 100644 --- a/v4l2/grabvidseq.c +++ b/v4l2/grabvidseq.c @@ -33,7 +33,6 @@ /* compilation control */ #define SAVE_AS_CUMUL 1 -#define SAVE_AS_PNM 0 #define SAVE_AS_FIMG 0 /* --------------------------------------------------------------------- */ @@ -190,6 +189,8 @@ if ((fmt.fmt.pix.width != width) || (fmt.fmt.pix.height != height)) { fmt.fmt.pix.width, fmt.fmt.pix.height); } +fprintf(stderr,"--- Ok 1\n"); + CLEAR(req); req.count = 2; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; @@ -242,16 +243,14 @@ else { fimg_clear(&cumul); cumul.fval = 255.0; /* must be read from camera XXX */ cumul.count = 0; - to_save = &cumul; #endif - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; xioctl(fd, VIDIOC_STREAMON, &type); -#if 0 -if (verbosity) fprintf(stderr,"pid %d grabbing %d picz...\n", +#if 1 +if (verbosity) fprintf(stderr,"pid %d is going to grab %d picz...\n", getpid(), nbre_capt); #endif @@ -273,31 +272,17 @@ for (i = 0; i < nbre_capt; i++) { } if(verbosity > 1) { - printf("%6d / %6d %9.3f\r", i, nbre_capt, + fprintf(stderr, "%6d / %6d %9.3f\n", i, nbre_capt, fimg_timer_get(0)); + fflush(stderr); } - CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; xioctl(fd, VIDIOC_DQBUF, &buf); -#if SAVE_AS_PNM - /* at this time,we'v got a picture in-memory, - so we can blast in on storage */ - sprintf(out_name, "%s/%05d.ppm", dest_dir, i); - if (verbosity > 1) fprintf(stderr, "--> %s\n", out_name); - fout = fopen(out_name, "w"); - if (!fout) { - perror("Cannot open image"); - exit(EXIT_FAILURE); - } - fprintf(fout, "P6\n%d %d 255\n", - fmt.fmt.pix.width, fmt.fmt.pix.height); - fwrite(buffers[buf.index].start, buf.bytesused, 1, fout); - fclose(fout); -#endif + fprintf(stderr, "xioctl VIDIOC_DQBUF done\n"); fflush(stderr); #if SAVE_AS_CUMUL if (upscaling) { diff --git a/v4l2/notes.txt b/v4l2/notes.txt new file mode 100644 index 00000000..71291fa6 --- /dev/null +++ b/v4l2/notes.txt @@ -0,0 +1,17 @@ + + +Heisenbug dans la capture d'image. + + + CLEAR(buf); + buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + buf.memory = V4L2_MEMORY_MMAP; + xioctl(fd, VIDIOC_DQBUF, &buf); + + +ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EAGAIN (Resource temporarily unavailable) +ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EAGAIN (Resource temporarily unavailable) +ioctl(3, VIDIOC_DQBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE^Cstrace: Process 11181 detached + + +