withDmaBuf<T> method

T withDmaBuf<T>(
  1. T use(
    1. ScopedDmaBufFrame view
    )
)

Gets the dmabuf of an acquired frame.

Wait for AcquiredFrameHandle.withProducerSync() before you read the buffer. Once you release or discard the frame, the session may render into the buffer again. You can map a buffer with DRM_FORMAT_MOD_LINEAR, which has one plane, with mmap, and bracket your reads with DMA_BUF_IOCTL_SYNC.

The session owns the planes' file descriptors, so don't close them. To keep the buffer after you release the frame, duplicate each file descriptor with dup. A duplicate keeps the buffer's memory, but not its contents.

See mln_acquired_frame_get_dma_buf in the C API reference.

Errors:

  • Status.targetLost when the session failed, or you detached, abandoned, or disposed it.

Implementation

T withDmaBuf<T>(T Function(ScopedDmaBufFrame view) use) => _NativeViewScope(
  _state,
  raw.mln_acquired_frame_view_begin,
  raw.mln_acquired_frame_view_end,
).use((scope) => use(ScopedDmaBufFrame._(scope, _getDmaBuf())));