PR #289: Improve ALSA audio stability
Pre-release
Pre-release
PR #289
Title: Improve ALSA audio stability
Source PR: WinNative-Emu/WinNative#289
Source branch: alsa-audiotrack-stability
Source commit: e1a9283e6e6c64b6f7acec14f5e756588762b067
Build workflow run: https://github.com/MaxsTechReview/WinNative/actions/runs/24953795207
What This PR Is About
Summary
This PR ports the Winlator 11-style ALSA playback path from brunodev85's winlator-app work into WinNative's ALSA server. Full credit for the upstream ALSA behavior and design goes to brunodev85: https://github.com/brunodev85
Changes
- Replace the Java ALSA server playback path from the old JNI AAudio wrapper to Android
AudioTrack. - Write audio with blocking full-buffer writes instead of a single one-shot native write.
- Track
AudioTrackunderruns and grow the playback buffer when underruns occur. - Detect Android
PROPERTY_OUTPUT_FRAMES_PER_BUFFERwhen the ALSA server starts, with a fallback of 256 frames. - Add ALSA playback options for latency, volume, and Android performance mode without adding a UI dialog.
- Read optional ALSA tuning values from existing container/shortcut env vars:
ANDROID_ALSA_LATENCY_MS/WINNATIVE_ALSA_LATENCY_MSANDROID_ALSA_VOLUME/WINNATIVE_ALSA_VOLUMEANDROID_ALSA_PERFORMANCE_MODE/WINNATIVE_ALSA_PERFORMANCE_MODE
- Copy shared-memory audio data into a private direct buffer before writing to Android audio.
- Pass ALSA options from launch env vars into the ALSA server component.
Expected Benefits
- Reduces long-session ALSA audio cutouts where audio can go silent after sustained gameplay.
- Handles short writes and Android audio underruns more gracefully.
- Allows per-container or per-shortcut ALSA latency tuning without changing UI.
- Keeps default behavior automatic: 16ms latency target, full volume, low-latency performance mode.
- Lowers shared-memory race risk between the guest ALSA writer and Android playback.
Attached Artifacts
- WinNative-Debug-Standard-PR.289-e1a92.apk
- WinNative-Debug-Ludashi-PR.289-e1a92.apk
- WinNative-Debug-Pubg-PR.289-e1a92.apk
Built from source commit e1a92.