Added SDL_HINT_ANDROID_LOW_LATENCY_AUDIO

This commit is contained in:
Sam Lantinga
2024-11-07 16:34:34 -08:00
parent 6836ef8fd2
commit 97dac37373
2 changed files with 17 additions and 1 deletions

View File

@@ -100,6 +100,22 @@ extern "C" {
*/
#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE"
/**
* A variable to control whether low latency audio should be enabled.
*
* Some devices have poor quality output when this is enabled, but this is usually an improvement in audio latency.
*
* The variable can be set to the following values:
*
* - "0": Low latency audio is not enabled.
* - "1": Low latency audio is enabled. (default)
*
* This hint should be set before SDL audio is initialized.
*
* \since This hint is available since SDL 3.1.8.
*/
#define SDL_HINT_ANDROID_LOW_LATENCY_AUDIO "SDL_ANDROID_LOW_LATENCY_AUDIO"
/**
* A variable to control whether we trap the Android back button to handle it
* manually.

View File

@@ -316,7 +316,7 @@ static bool BuildAAudioStream(SDL_AudioDevice *device)
ctx.AAudioStreamBuilder_setErrorCallback(builder, AAUDIO_errorCallback, device);
ctx.AAudioStreamBuilder_setDataCallback(builder, AAUDIO_dataCallback, device);
// 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", true)) {
if (SDL_GetHintBoolean(SDL_HINT_ANDROID_LOW_LATENCY_AUDIO, true)) {
SDL_Log("Low latency audio enabled\n");
ctx.AAudioStreamBuilder_setPerformanceMode(builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
} else {