withIoSurface<T> method

T withIoSurface<T>(
  1. T use(
    1. ScopedIoSurfaceFrame view
    )
)

Gets the IOSurface of an acquired frame.

Wait for AcquiredFrameHandle.withProducerSync() before you read the surface. Once you release or discard the frame, the session may render into the surface again. For an API that takes a CVPixelBuffer, wrap the surface with CVPixelBufferCreateWithIOSurface. A reference that you take with CFRetain, or a pixel buffer that wraps the surface, keeps the surface's memory, but not its contents.

See mln_acquired_frame_get_io_surface in the C API reference.

Errors:

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

Implementation

T withIoSurface<T>(T Function(ScopedIoSurfaceFrame view) use) =>
    _NativeViewScope(
      _state,
      raw.mln_acquired_frame_view_begin,
      raw.mln_acquired_frame_view_end,
    ).use((scope) => use(ScopedIoSurfaceFrame._(scope, _getIoSurface())));