acquireFrame method

AcquiredFrameHandle? acquireFrame()

Takes the newest rendered frame from the session's texture ring, if one is ready.

Older frames that you haven't acquired are dropped, and the session can render over a frame before you acquire it. While you hold a frame in every texture of the ring, new frames wait until you release one. When no frame is ready, it succeeds and writes the null handle.

See mln_render_session_acquire_frame in the C API reference.

Errors:

  • Status.unsupported when the session lacks RenderSessionCapabilityFlag.frameAcquisition.
  • Status.targetLost or Status.nativeError, as RenderSessionSnapshot.failureStatus reports, when the session has failed.
  • Status.invalidState when you detached, abandoned, released, or disposed the session.

Implementation

AcquiredFrameHandle? acquireFrame() => withNativeArena((arena) {
  final outFrame = arena<Uint64>();
  _check(
    raw.mln_render_session_acquire_frame(
      _handle.raw,
      outFrame,
      nativeDiagnostic,
    ),
  );
  if (outFrame.value == 0) {
    return null;
  }
  return _adoptOwned(
    outFrame.value,
    () => AcquiredFrameHandle._(this, _NativeAcquiredFrame(outFrame.value)),
    (handle) {
      _check(raw.mln_acquired_frame_discard(handle, nativeDiagnostic));
    },
  );
});