We are using the tegra multimedia API to encode H264 video received from a camera on a Jetson TX2.
We have been having an issue with dequeuing buffers for encoding. We are using code that was taken from the examples with a few modifications to integrate into our project and are seeing the dqBuffer() method of the NvV4l2ElementPlane class for the capture plane blocking, specifically the call to :
ret = v4l2_ioctl(fd, VIDIOC_DQBUF, &v4l2_buf);
I have ensured this is opened using O_NONBLOCK ,
, and I am also ensuring there are buffers available in the queue. This application runs reliably on Jetpack 3.1 but am having issues with Jetpack 3.3. Very often the dqBuffer() method will block for 10 seconds before returning. I will get anywhere from 1 to 10 buffers dequeued before it wedges permanently. This doesn’t happen every time or on every device, but it happens more often than not. I have added logging to narrow the problem so I could see exactly where the problem is, and very often this will fix the problem. I will delete the logging and the problem will be back. Occasionally I can repeat the problem with the logging, and that is how I have been able to trace the source of the problem.
I have tried both the V4L2_MEMORY_MMAP and V4L2_MEMORY_DMABUF options for the buffers and get the similar results although it seems to be a little bit better with the DMA option.
This looks very much like some sort of race condition internally and I have no idea what might be causing it.
I am wondering if anyone else has seen anything else like this or if anyone might have an idea what is happening?