Parcourir la source

Added SDL_HINT_ANDROID_LOW_LATENCY_AUDIO

Sam Lantinga il y a 5 mois
Parent
commit
97dac37373
2 fichiers modifiés avec 17 ajouts et 1 suppressions
  1. 16 0
      include/SDL3/SDL_hints.h
  2. 1 1
      src/audio/aaudio/SDL_aaudio.c

+ 16 - 0
include/SDL3/SDL_hints.h

@@ -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.

+ 1 - 1
src/audio/aaudio/SDL_aaudio.c

@@ -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 {