MCPcopy Create free account
hub / github.com/RustCV/RustCV / dequeue_buffer

Function dequeue_buffer

rustcv-camera/src/backend/linux/sys.rs:318–326  ·  view source on GitHub ↗

Dequeue a buffer — retrieve a filled buffer from the driver (VIDIOC_DQBUF). 将缓冲区出队 —— 从驱动取回已写满数据的缓冲区(VIDIOC_DQBUF)。 This call **blocks** until a frame is ready. No `poll()`/`select()` is used, which saves one syscall per frame compared to the `v4l` crate's approach. 此调用会**阻塞**直到帧就绪。不使用 `poll()`/`select()`, 相比 `v4l` crate 的做法每帧节省一次系统调用。 The returned `v4l2_buffer` contains: - `index`: which buffer

(fd: RawFd)

Source from the content-addressed store, hash-verified

316/// - `sequence`:驱动分配的帧序号(用于丢帧检测)
317/// - `timestamp`:内核时间戳
318pub fn dequeue_buffer(fd: RawFd) -> io::Result<v4l2_buffer> {
319 let mut buf: v4l2_buffer = unsafe { std::mem::zeroed() };
320 buf.type_ = V4L2_BUF_TYPE_VIDEO_CAPTURE;
321 buf.memory = V4L2_MEMORY_MMAP;
322 unsafe {
323 v4l2_ioctl(fd, VIDIOC_DQBUF, &mut buf as *mut _ as *mut libc::c_void)?;
324 }
325 Ok(buf)
326}
327
328// ─── Stream control ─────────────────────────────────────────────────────────
329

Callers 1

dequeueMethod · 0.85

Calls 1

v4l2_ioctlFunction · 0.85

Tested by

no test coverage detected