From 5cdf4df765cdd510dbdfd97f4e4372fb444e256e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 25 Oct 2026 13:49:04 +0100 Subject: [PATCH] Android: Don't enable MMAP beyond the device's own policy setMMapEnabled(true) doesn't mean "allow it", it sets the process's MMAP policy to AUTO, overriding a device whose aaudio.mmap_policy disables MMAP. Since #22766 we did that on every audio start, and a Xiaomi Pad 5 Pro (Android 13) has been stuck on a blank screen at launch since then. The likely cause, not yet confirmed on the device: opening a stream on a MMAP path the vendor turned off, from the UI thread. Now the checkbox can only turn MMAP off, as on the Bluetooth TV. Co-Authored-By: Claude Opus 5.5 (1M context) --- android/jni/OboeContext.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/android/jni/OboeContext.cpp b/android/jni/OboeContext.cpp index f45866f404..15815ce064 100644 --- a/android/jni/OboeContext.cpp +++ b/android/jni/OboeContext.cpp @@ -21,8 +21,10 @@ public: if (g_Config.iAndroidAudioApi == (int)AndroidAudioApi::AAUDIO && oboe::AudioStreamBuilder::isAAudioRecommended()) { audioApi_ = oboe::AudioApi::AAudio; } - // Global in Oboe, and only read when an AAudio stream is opened. - oboe::OboeExtensions::setMMapEnabled(g_Config.bAndroidAudioMMap); + // Global in Oboe, and only read when an AAudio stream is opened. Never enable it beyond what + // the device's aaudio.mmap_policy allows: setMMapEnabled(true) forces the policy to AUTO, and + // a Xiaomi Pad 5 Pro (Android 13) got stuck on a blank screen at launch after we started doing that. + oboe::OboeExtensions::setMMapEnabled(g_Config.bAndroidAudioMMap && oboe::OboeExtensions::isMMapSupported()); } bool StartOutput() {