Skip to contentSkip to conversation

v4l2-utils: libv4l2: Remove unconditional sleep after STREAMOFF and enable REQBUFS(count=0)

PATCH New Rivka S 1 participant 1 message Feb 17

lore
Share & tools
lore

Rivka S

author
#0 lore raw

PATCH 1/1 v4l2-utils: libv4l2: Remove unconditional sleep after STREAMOFF and enable REQBUFS(count=0)

Remove the unconditional sleep(1) after VIDIOC_STREAMOFF and enable the REQBUFS(count=0) call when freeing buffers.

The current implementation calls sleep(1) after STREAMOFF with a FIXME comment suggesting a need to ensure that all buffers have stopped. However, the videobuf2 implementation documents that vb2_core_streamoff() cancels the queue and removes all buffers from the driver and vb2, returning control to userspace as part of the stream stop procedure.

Since STREAMOFF already performs queue cancellation, remove the additional sleep delay as is it unnecessary and does not provide deterministic synchronization.

Re-enable the REQBUFS(count=0) call, which was previously disabled due to historical limitations in the old video-buf implementation. Modern buffer frameworks expect this ioctl to release all buffers as defined by the V4L2 API.

---
 utils/libv4l2util/v4l2_driver.c | 6 ------
 1 file changed, 6 deletions(-)
utils/libv4l2util/v4l2_driver.c +0 -6
index c9560326..28fc1bcf 100644
@@ -569,17 +569,11 @@ int v4l2_free_bufs(struct v4l2_driver *drv)
 	if (xioctl(drv->fd,VIDIOC_STREAMOFF,&drv->reqbuf.type)<0)
 		return errno;
 
-	sleep (1);	// FIXME: Should check if all buffers are stopped
 
-/* V4L2 API says REQBUFS with count=0 should be used to release buffer.
-   However, video-buf.c doesn't implement it.
- */
-#if 0
 	if (xioctl(drv->fd,VIDIOC_REQBUFS,&drv->reqbuf)<0) {
 		perror("reqbufs while freeing buffers");
 		return errno;
 	}
-#endif
 
 	if (drv->reqbuf.count != 0) {
 		fprintf(stderr,"REQBUFS returned %d buffers while asking for freeing it!\n",
Signature · 1 line
2.43.0