Skip to content

Fix AAudio builder requested device id during stream open#2353

Merged
robertwu1 merged 1 commit intomainfrom
robertwu/fixdeviceidsetter
Mar 19, 2026
Merged

Fix AAudio builder requested device id during stream open#2353
robertwu1 merged 1 commit intomainfrom
robertwu/fixdeviceidsetter

Conversation

@robertwu1
Copy link
Copy Markdown
Collaborator

The recent routing changed callback patch overrode getDeviceId() in
AudioStreamAAudio to dynamically return the mUpdatedDeviceIds array.

However, this caused a critical initialization bug.

During stream creation in AudioStreamAAudio::open(), the builder was
configured via builder_setDeviceId(aaudioBuilder, getDeviceId()). Because
mUpdatedDeviceIds is unpopulated until the very end of the open()
sequence, getDeviceId() evaluated to an empty array and prematurely
returned 0 (kUnspecified).

As a result, Oboe was completely ignoring the app's requested device
ID and strictly routing to the default microphone and speaker.
This explicitly queries AudioStreamBase::getDeviceId() during builder
initialization to correctly retrieve the app's originally requested
device ID, avoiding the overridden dynamic routing array.

@robertwu1 robertwu1 requested a review from flamme March 19, 2026 22:02
Copy link
Copy Markdown
Collaborator

@flamme flamme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the excellent debugging and fast fix!

@robertwu1 robertwu1 merged commit 5a58c7b into main Mar 19, 2026
3 checks passed
@robertwu1 robertwu1 deleted the robertwu/fixdeviceidsetter branch March 19, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants