Default SpatializationBehavior to Auto and make Never opt-in - #2421
Merged
Merged
Conversation
robertwu1
force-pushed
the
spatialization-auto-default
branch
from
September 15, 2026 20:31
07772b1 to
41ef541
Compare
robertwu1
force-pushed
the
spatialization-auto-default
branch
3 times, most recently
from
September 15, 2026 21:27
4a0f6d3 to
78a18d1
Compare
flamme
reviewed
Sep 15, 2026
robertwu1
force-pushed
the
spatialization-auto-default
branch
from
September 15, 2026 22:44
78a18d1 to
dc717d3
Compare
flamme
reviewed
Sep 15, 2026
robertwu1
force-pushed
the
spatialization-auto-default
branch
from
September 15, 2026 23:14
dc717d3 to
14a882f
Compare
flamme
approved these changes
Sep 15, 2026
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.
Motivation
Previously, Oboe explicitly overrode
SpatializationBehavior::UnspecifiedtoSpatializationBehavior::Neverby default (added in commit9e24a77022d20cf89c4a444873e8a82b72781b6d, PR #1776) with a comment// Override Unspecified as Never to reduce latency, and also defaultedmSpatializationBehaviortoNeveron API <= 31 and OpenSL ES.However, overriding
UnspecifiedtoNeverprevents Android XR from spatializing 2D panel app audio for apps using Oboe. WhenAAudioStreamBuilder_setSpatializationBehavioris not called (or set toAAUDIO_UNSPECIFIED), AAudio's native default on API 32+ isAAUDIO_SPATIALIZATION_BEHAVIOR_AUTO(and on API <= 31 / OpenSL ES, the system uses its default automatic behavior).Therefore,
SpatializationBehavior::Autoshould be the default everywhere (mirroring the system's default behavior), andSpatializationBehavior::Nevershould be opt-in (supported on AAudio API 32+).Empirical Latency & MMAP Verification
We ran an empirical stream-open matrix on an attached Pixel 10 (
frankel, Android 17 / API 37) comparingSpatializationBehavior::AutovsSpatializationBehavior::NeveracrossPerformanceMode(LowLatencyandNone),SharingMode(SharedandExclusive), and channel counts (2Stereo and65.1 Surround):LowLatencySharedAutoLowLatencySharedLowLatencySharedNeverLowLatencySharedLowLatencyExclusiveAutoLowLatencyExclusiveLowLatencyExclusiveNeverLowLatencyExclusiveLowLatencyShared/ExclusiveAutoNoneSharedLowLatencyShared/ExclusiveNeverNoneSharedNoneShared/ExclusiveAutoNoneSharedNoneShared/ExclusiveNeverNoneSharedSpatializationBehavior::Autohas zero impact on low-latency stereo streams (AUDIO_OUTPUT_FLAG_MMAP_NOIRQ/AUDIO_OUTPUT_FLAG_FASTare preserved with identical 96-frame bursts and MMAP paths), while enabling Android XR to spatialize 2D panel app audio automatically.Changes
src/aaudio/AudioStreamAAudio.cpp: DefaultSpatializationBehavior::UnspecifiedtoSpatializationBehavior::Auto(and setmSpatializationBehavior = SpatializationBehavior::Autowhenbuilder_setSpatializationBehavior == nullptron API <= 31).src/opensles/AudioStreamOpenSLES.cpp: SetmSpatializationBehavior = SpatializationBehavior::Autosince OpenSL ES does not support opting out viaNeverand always uses the system's default behavior.include/oboe/AudioStreamBuilder.h: Update documentation comment forsetSpatializationBehaviorto state thatSpatializationBehavior::Autois the default andSpatializationBehavior::Neveris only supported on API 32 and above for AAudio.tests/testStreamOpen.cpp: Update spatialization unit tests (AAudioInputSetSpatializationBehavior,AAudioOutputSetSpatializationBehavior,OpenSLESOutputSetSpatializationBehavior,AAudioInputSetSpatializationBehaviorUnspecified, andAAudioOutputSetSpatializationBehaviorUnspecified) to test thatAutois the default everywhere andNeveris opt-in on API 32+ AAudio.Testing
testStreamOpen.cppand the full 242-test GoogleTest suite on Pixel 10 (frankel, Android 17 / API 37).