Audio capture latency reduction #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to solve the outstanding audio capture latency issue. Recently, #122 fixed an issue related to video capture that was causing broader performance impacts, leading to high audio latency over time when both video and audio were enabled. Currently, audio samples are read using
OnAudioFilterRead
, enqueued, and then dequeued and captured via FFI on a dedicated thread. Based on the code history, it seems this might have been introduced as a fix for audio delay. With the issue from #122 fixed, this PR evaluates the performance of capturing directly fromOnAudioFilterRead
with no additional queuing on the Unity side; my initial testing on iOS and macOS shows this works well, delivering noticibly lower audio latency that does not increase over time.I would like to discuss potential impacts of this change and test across more platforms. Also, it is worth noting since the last discussion about this in #62, the
queue_size_ms
option has been added by livekit/rust-sdks#425 but has not been adopted yet.Related PRs and discussion in chronological order:
enable_queue
option removed, replaced byqueue_size_ms