From 0df888c584ed525096083d0f6b1444324280f4a2 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 19 Oct 2023 08:54:11 -0700
Subject: [PATCH] Moved Android low latency audio behind a hint
"SDL_ANDROID_LOW_LATENCY_AUDIO"
---
src/audio/aaudio/SDL_aaudio.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c
index f1f8674b743e..9d9c98b8eec5 100644
--- a/src/audio/aaudio/SDL_aaudio.c
+++ b/src/audio/aaudio/SDL_aaudio.c
@@ -311,9 +311,10 @@ static int BuildAAudioStream(SDL_AudioDevice *device)
ctx.AAudioStreamBuilder_setDirection(builder, direction);
ctx.AAudioStreamBuilder_setErrorCallback(builder, AAUDIO_errorCallback, device);
ctx.AAudioStreamBuilder_setDataCallback(builder, AAUDIO_dataCallback, device);
-#if 0 // Some devices have flat sounding audio when low latency mode is enabled
- ctx.AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
-#endif
+ // Some devices have flat sounding audio when low latency mode is enabled, but this is a better experience for most people
+ if (SDL_GetHintBoolean("SDL_ANDROID_LOW_LATENCY_AUDIO", SDL_TRUE)) {
+ ctx.AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
+ }
LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u",
device->spec.freq, SDL_AUDIO_BITSIZE(device->spec.format),