V4L2 : heisenbug spotted around VIDIOC_DQBUF, infinite loop

This commit is contained in:
tonton th 2020-12-26 18:37:04 +01:00
parent ce96b51ca4
commit 14ded65303
2 changed files with 24 additions and 22 deletions

View File

@ -33,7 +33,6 @@
/* compilation control */ /* compilation control */
#define SAVE_AS_CUMUL 1 #define SAVE_AS_CUMUL 1
#define SAVE_AS_PNM 0
#define SAVE_AS_FIMG 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); fmt.fmt.pix.width, fmt.fmt.pix.height);
} }
fprintf(stderr,"--- Ok 1\n");
CLEAR(req); CLEAR(req);
req.count = 2; req.count = 2;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
@ -242,16 +243,14 @@ else {
fimg_clear(&cumul); fimg_clear(&cumul);
cumul.fval = 255.0; /* must be read from camera XXX */ cumul.fval = 255.0; /* must be read from camera XXX */
cumul.count = 0; cumul.count = 0;
to_save = &cumul; to_save = &cumul;
#endif #endif
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
xioctl(fd, VIDIOC_STREAMON, &type); xioctl(fd, VIDIOC_STREAMON, &type);
#if 0 #if 1
if (verbosity) fprintf(stderr,"pid %d grabbing %d picz...\n", if (verbosity) fprintf(stderr,"pid %d is going to grab %d picz...\n",
getpid(), nbre_capt); getpid(), nbre_capt);
#endif #endif
@ -273,31 +272,17 @@ for (i = 0; i < nbre_capt; i++) {
} }
if(verbosity > 1) { 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)); fimg_timer_get(0));
fflush(stderr);
} }
CLEAR(buf); CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP; buf.memory = V4L2_MEMORY_MMAP;
xioctl(fd, VIDIOC_DQBUF, &buf); xioctl(fd, VIDIOC_DQBUF, &buf);
#if SAVE_AS_PNM fprintf(stderr, "xioctl VIDIOC_DQBUF done\n"); fflush(stderr);
/* 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
#if SAVE_AS_CUMUL #if SAVE_AS_CUMUL
if (upscaling) { if (upscaling) {

17
v4l2/notes.txt Normal file
View File

@ -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