Skip to content

DirectAudio: audio switching + guarded setUsage (#1806 review) - #7

Merged
joshuatam merged 1 commit into
joshuatam:feat/directaudiofrom
The412Banner:directaudio-switching-usage
Aug 12, 2026
Merged

DirectAudio: audio switching + guarded setUsage (#1806 review)#7
joshuatam merged 1 commit into
joshuatam:feat/directaudiofrom
The412Banner:directaudio-switching-usage

Conversation

@The412Banner

Copy link
Copy Markdown

Addresses the two review comments on utkarshdalal#1806 by updating the bundled directaudio-20260812.tzst to a rebuilt driver (drop-in: same filename/layout, no code changes).

1. Audio switching (aaudio_error_callback) — the mixer now reopens the AAudio output on INVALID_STATE / INVALID_HANDLE / TIMEOUT as well as DISCONNECTED, matching GameNative/pulseaudio-android module-aaudio-sink.c. While testing on-device I found broadening the trigger set caused a reopen churn (the reopen's own teardown/startup fired more reopens) and the one-shot guard could drop a real request mid-flight → audio died after 2–3 route changes. Fixed with (a) a stream-identity guard so only the live/promoted stream's errors trigger a reopen, and (b) a reopen gate that can't lose a wakeup. Held solid for 7 headphone/BT + background↔foreground cycles on-device.

2. AAudioStreamBuilder_setUsage — added AAUDIO_USAGE_GAME, resolved via dlsym + android_get_device_api_level() >= 28 rather than a direct call. The unixlib direct-links libaaudio (eager symbol binding at dlopen), so a direct setUsage reference would fail the .so load on minSdk-26 / Android 8. dlsym keeps it loadable everywhere and only applies the hint on API 28+.

Driver source: The412Banner/directaudio @ branch feat/directaudio-switching-usage. Built arm64ec, 16KB-page .so (loads on both 4KB and 16KB devices).

Rebuilt directaudio-20260812.tzst from The412Banner/directaudio branch
feat/directaudio-switching-usage (v1 + the two utkarshdalal#1806 review comments):
- broadened AAudio error-callback recovery (INVALID_STATE/INVALID_HANDLE/
  TIMEOUT as well as DISCONNECTED), matching module-aaudio-sink.c, with a
  stream-identity guard + no-lost-wakeup reopen gate (device-proven, 7
  route/bg-fg cycles, no drops).
- AAUDIO_USAGE_GAME via dlsym + android_get_device_api_level()>=28 guard
  (the unixlib direct-links libaaudio; a direct ref would fail .so load on
  minSdk 26 / Android 8).
Same filename/layout; arm64ec, 16KB-page .so (loads on 4KB+16KB).
@joshuatam
joshuatam merged commit cdce44d into joshuatam:feat/directaudio Aug 12, 2026
joshuatam pushed a commit that referenced this pull request Aug 19, 2026
Rebuilt directaudio-20260812.tzst from The412Banner/directaudio branch
feat/directaudio-switching-usage (v1 + the two utkarshdalal#1806 review comments):
- broadened AAudio error-callback recovery (INVALID_STATE/INVALID_HANDLE/
  TIMEOUT as well as DISCONNECTED), matching module-aaudio-sink.c, with a
  stream-identity guard + no-lost-wakeup reopen gate (device-proven, 7
  route/bg-fg cycles, no drops).
- AAUDIO_USAGE_GAME via dlsym + android_get_device_api_level()>=28 guard
  (the unixlib direct-links libaaudio; a direct ref would fail .so load on
  minSdk 26 / Android 8).
Same filename/layout; arm64ec, 16KB-page .so (loads on 4KB+16KB).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants