feat: add hardware latency reporting to ASIO, CoreAudio, JACK, WASAPI and WebAudio#1129
Open
roderickvd wants to merge 2 commits intomasterfrom
Open
feat: add hardware latency reporting to ASIO, CoreAudio, JACK, WASAPI and WebAudio#1129roderickvd wants to merge 2 commits intomasterfrom
roderickvd wants to merge 2 commits intomasterfrom
Conversation
This was referenced Mar 17, 2026
830bbd0 to
793001c
Compare
793001c to
81c71de
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves cross-backend timestamp accuracy by incorporating driver-/platform-reported latency components into OutputStreamTimestamp (and related input timestamps where applicable), making callback timing metadata better reflect when audio is actually captured/played by hardware.
Changes:
- WebAudio/WebAudioWorklet: incorporate
baseLatencyandoutputLatencyinto output playback timestamps. - WASAPI: compute output playback timestamps using endpoint buffer padding plus
IAudioClient::GetStreamLatency(). - CoreAudio/JACK/ASIO: refine timestamps using device latency + safety offset (CoreAudio), cycle deadline (JACK), and ASIO driver-reported hardware latency (ASIO + asio-sys bindings).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/host/webaudio/mod.rs | Adds base/output latency compensation when reporting output playback timestamps. |
| src/host/audioworklet/mod.rs | Snapshots WebAudio latency values and factors them into worklet output playback timestamps. |
| src/host/wasapi/stream.rs | Updates output timestamp calculation to use buffer padding + stored stream latency. |
| src/host/wasapi/device.rs | Captures WASAPI stream latency during stream construction and stores it in StreamInner. |
| src/host/jack/stream.rs | Uses JACK cycle next_usecs (when available) for more precise output playback timestamps. |
| src/host/coreaudio/macos/device.rs | Adds device latency + safety offset to CoreAudio timestamp delay computation. |
| src/host/asio/stream.rs | Incorporates ASIO driver latency frames into input/output timestamp delay calculations. |
| asio-sys/src/bindings/mod.rs | Exposes Driver::latencies() wrapping ASIOGetLatencies. |
| asio-sys/build.rs | Allowlists ASIOGetLatencies for bindgen-generated bindings. |
| asio-sys/asio_stub_bindings.rs | Adds a stub ASIOGetLatencies symbol for docs/non-Windows builds. |
| CHANGELOG.md | Documents improved timestamp behavior across backends. |
| asio-sys/CHANGELOG.md | Documents the newly added Driver::latencies() API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently,
playback - callbackunderreports host latency on several hosts because the hardware pipeline delay isn't included.This PR fixes it using each host's native API:
kAudioDevicePropertyLatency + kAudioDevicePropertySafetyOffsetGetStreamLatency()(hardware latency beyond the buffer)ASIOGetLatencies()(hardware latency beyond the buffer)CycleTimes::next_usecsdirectly instead of estimating fromcurrent_usecs + buffer_durationAudioContext.baseLatency + outputLatencySupersedes #964
Fixes #773