reset method

Future<void> reset()

Stops recording and clears buffered audio and listeners so the instance can be reused.

Implementation

Future<void> reset() async {
  await stopRecording();
  _timeoutTimer?.cancel();
  await _participantStateListener?.call();
  _participantStateListener = null;
  _buffer.clear();

  // Keep the local track because the Room still uses it.
  _localTrack = null;

  _agentReadyManager.reset();
  _localTrackPublishedEvent = null;

  // Reset the _isSent flag to allow data sending on next use
  _isBufferSent = false;
  _hasLoggedOverflow = false;
  _renderedSampleRate = null;
  _renderedChannels = null;

  logger.info('[Preconnect audio] reset');
}