You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d1fe342
Browse filesBrowse the repository at this point in the historyBrowse files
Apply audio processing options when local capture starts (#1115)
## Summary
- move create-time audio processing setup into the local capture start
path so publish/preconnect prepares platform audio processing before
WebRTC opens the microphone, matching the Swift SDK flow
- keep `LocalAudioTrack.setAudioProcessingOptions` as a command-style
runtime API that returns on success and throws
`AudioProcessingException` on failure
- expose structured failure reasons for invalid combinations,
unavailable platform support, native apply failures, and unknown
failures
- clean up local audio tracks when capture/publish startup fails and
keep cleanup failures from masking the original error
- bump `flutter_webrtc` to `1.5.2` for Android audio device module
access
## Behavior
- `LocalAudioTrack.create(...)` stores requested audio processing
options; it no longer attempts to apply them immediately.
- `track.start()` starts local capture and applies stored processing
options before the microphone opens on supported platforms.
- Publish and preconnect paths fail during capture start if the exposed
native platform API reports audio processing setup failure.
- Runtime `setAudioProcessingOptions(...)` still applies immediately for
active local audio tracks and throws on failed native apply/store.
- Android uses `JavaAudioDeviceModule.prewarmRecording(options)`. That
WebRTC API returns `void`, so this PR can surface thrown failures, but
clean internal `false` returns from `initRecordingIfNeeded()` /
`prewarmRecordingIfNeeded()` are not observable until
WebRTC/flutter_webrtc exposes a resultful API.
## Testing
- `flutter pub get`
- `flutter pub get` in `example`
- `flutter analyze --no-pub`
- `flutter test --no-pub`
- `flutter build apk --debug --no-pub` in `example`
- Android emulator smoke test: example joined a room, published local
microphone audio, muted/unpublished, and showed no
ADM/platform-unavailable errors
Copy file name to clipboardExpand all lines: docs/audio.md
+17-7Lines changed: 17 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,24 +108,34 @@ final now = AudioManager.instance.audioEngineState;
108
108
109
109
Session management is one half of the audio stack. The other half is audio processing, the signal processing applied to captured audio such as echo cancellation, noise suppression, auto gain control, and the high pass filter. `AudioManager` is the home for both, and they compose cleanly.
110
110
111
-
The session intent decides how the platform treats audio. Processing options decide what happens to captured local microphone audio:
111
+
The session intent decides how the platform treats audio. Capture options decide what happens to local microphone audio:
112
112
113
113
- A call usually uses the automatic `communication` session. The default `AudioCaptureOptions` enable echo cancellation, noise suppression, and auto gain control, while leaving the high pass filter off.
114
114
- Use `AudioProcessingOptions.communication()` when you want all four voice filters on for an existing local audio track.
115
115
- Use `AudioProcessingOptions.noProcessing()` for local capture where you want minimal processing, such as high quality recording or app-managed audio effects.
116
116
117
-
Processing is applied per local audio track. A malformed request (an incompatible mode, or a remote track) throws, while a request the platform could not honor comes back as an unsuccessful result:
117
+
Create-time processing is configured through `AudioCaptureOptions`. `LocalAudioTrack.create(...)` stores these options, and LiveKit prepares them when local recording starts, such as during publish or preconnect. If the exposed native platform API reports that capture-time setup failed, the start path throws `AudioProcessingException` before publish creates a server-side publication.
118
+
119
+
```dart
120
+
final track = await LocalAudioTrack.create(
121
+
const AudioCaptureOptions(
122
+
echoCancellation: true,
123
+
noiseSuppression: true,
124
+
autoGainControl: true,
125
+
highPassFilter: false,
126
+
),
127
+
);
128
+
```
129
+
130
+
For an existing local audio track, call `setAudioProcessingOptions`. It returns when the native layer applies or stores the options. If the request is invalid, unsupported, or cannot be applied, it throws `AudioProcessingException` and the track keeps its previous processing options.
118
131
119
132
```dart
120
133
try {
121
-
final result = await localAudioTrack.setAudioProcessingOptions(
134
+
await localAudioTrack.setAudioProcessingOptions(
122
135
const AudioProcessingOptions.noProcessing(),
123
136
);
124
-
if (!result.isSuccess) {
125
-
print('audio processing not applied: ${result.code.value} ${result.message}');
0 commit comments