withAndroidHardwareBuffer<T> method

T withAndroidHardwareBuffer<T>(
  1. T use(
    1. ScopedAndroidHardwareBufferFrame view
    )
)

Gets the Android hardware buffer 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. A reference that you take with AHardwareBuffer_acquire keeps the buffer's memory, but not its contents.

See mln_acquired_frame_get_android_hardware_buffer in the C API reference.

Errors:

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

Implementation

T withAndroidHardwareBuffer<T>(
  T Function(ScopedAndroidHardwareBufferFrame view) use,
) =>
    _NativeViewScope(
      _state,
      raw.mln_acquired_frame_view_begin,
      raw.mln_acquired_frame_view_end,
    ).use(
      (scope) => use(
        ScopedAndroidHardwareBufferFrame._(
          scope,
          _getAndroidHardwareBuffer(),
        ),
      ),
    );