launch method

Future<AudioIsolateLaunchedResponse> launch({
  1. TInitialMessage? initialMessage,
})

Implementation

Future<AudioIsolateLaunchedResponse> launch({TInitialMessage? initialMessage}) async {
  if (_session != null) {
    throw StateError('AudioIsolate is already running');
  }

  final isolate = await Isolate.spawn(
    _audioIsolateRunner,
    _messenger.workerToHostSendPort,
    paused: true,
  );
  final session = _AudioIsolateSession(initialMessage, isolate);
  _session = session;

  isolate.resume(isolate.pauseCapability!);

  return session.launchCompleter.future;
}