start method
Opens sourceId, or the system's default microphone when it is null,
requesting permission if it has not been granted. Returns once frames
are flowing; a second call while running does nothing, whatever
sourceId it names.
The default and an XAudioSourceKind.microphone id capture under the
platform's voice processing when voiceProcessing is true (the default),
so what the device plays does not re-enter as local speech. False leaves
the microphone raw — no echo cancellation and no output ducking. An
XAudioSourceKind.playback id taps that output instead, and runs
without voice processing.
Changing source is stop then start: one tap runs at a time and nothing is mixed.
Throws XAudioCaptureException when the tap cannot open — unknown_source
when sourceId names nothing sources lists.
Implementation
@override
Future<void> start({String? sourceId, bool voiceProcessing = true}) =>
_enqueue(() async {
if (!supported) {
throw XAudioCaptureException('unsupported', '$defaultTargetPlatform');
}
try {
await _methods.invokeMethod<void>(
'start',
_startArguments(
sourceId: sourceId,
voiceProcessing: voiceProcessing,
),
);
} on PlatformException catch (e) {
throw XAudioCaptureException(e.code, e.message);
}
});