pushAudio method

void pushAudio(
  1. Uint8List audio
)

Push one binary audio chunk. Blocks while the internal channel is full (backpressure propagation).

Implementation

void pushAudio(Uint8List audio) {
  _checkOpen();
  final ptr = audio.isEmpty
      ? Pointer<Uint8>.fromAddress(0)
      : calloc<Uint8>(audio.length);
  final allocated = audio.isNotEmpty;
  try {
    if (allocated) {
      ptr.asTypedList(audio.length).setAll(0, audio);
    }
    expectAimuxError(_ffi.transcriptionPushAudio(_handle, ptr, audio.length),
        'transcription_push_audio');
  } finally {
    if (allocated) calloc.free(ptr);
  }
}