aaudio: rework buffer sizing strategy, treat latency as performance hint#836
Open
aaudio: rework buffer sizing strategy, treat latency as performance hint#836
Conversation
36f6f58 to
d7e0596
Compare
For output, use 2 bursts (matching Oboe defaults) for low-latency streams and keep defaults for power-saving; for input, maximize buffer size to reduce XRuns. Remove hardcoded setFramesPerDataCallback/ setBufferCapacityInFrames and let AAudio choose optimal values. Check the actual performance mode granted by AAudio rather than the requested latency to decide whether to tune the output buffer. This avoids shrinking the buffer below AAudio's default when the mode is downgraded (e.g. Bluetooth routing).
d7e0596 to
29953c6
Compare
Collaborator
Author
|
This is green on CI. |
Pehrsons
approved these changes
Mar 24, 2026
Contributor
Pehrsons
left a comment
There was a problem hiding this comment.
LGTM
I trust you've done a fair bit of manual testing across devices (phones and headphones) here.
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.
Rework our AAudio backend's buffer sizing strategy based on AAudio best practices and a thorough review of the decisions made in liboboe and Chromium. Also only do buffer size tuning if
LOW_LATENCYperformance mode was actually granted.Note that we no longer call
setFramesPerDataCallback, so we'll get data callbacks in AAudio's preferred size rather than forcing sizes that could result in internal buffering in AAudio. I think this will be better for latency/performance, but if it turns out to be problematic we can revisit this.This also makes
0005-increase-aaudio-powersaving-buffering.patchin Gecko obsolete, so it will be dropped when this change is imported.