SDL: Added SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE

From f05cd850485845a69dcaa9f78cfc3f3ee1f2bd6f Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 3 Aug 2024 08:04:46 -0700
Subject: [PATCH] Added SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE

---
 include/SDL3/SDL_hints.h        | 11 +++++++++++
 src/audio/alsa/SDL_alsa_audio.c |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/SDL3/SDL_hints.h b/include/SDL3/SDL_hints.h
index 8982ffc0f8921..3da8a25ddafea 100644
--- a/include/SDL3/SDL_hints.h
+++ b/include/SDL3/SDL_hints.h
@@ -197,6 +197,17 @@ extern "C" {
  */
 #define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION"
 
+/**
+ * Specify the default ALSA audio device name.
+ *
+ * This variable is a specific audio device to open when the "default" audio device is used. By default if 4 channel audio is requested, the "plug:surround40" device will be opened and if 6 channel audio is requested the "plug:surround51" device will be opened.
+ *
+ * This hint should be set before an audio device is opened.
+ *
+ * \since This hint is available since SDL 3.0.0.
+ */
+#define SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE "SDL_AUDIO_ALSA_DEFAULT_DEVICE"
+
 /**
  * A variable controlling the audio category on iOS and macOS.
  *
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index e2827f418d4b1..7513c92043c5a 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -228,7 +228,7 @@ static const char *get_audio_device(void *handle, const int channels)
 
     ALSA_Device *dev = (ALSA_Device *)handle;
     if (SDL_strcmp(dev->name, "default") == 0) {
-        const char *device = SDL_getenv("AUDIODEV"); // Is there a standard variable name?
+        const char *device = SDL_GetHint(SDL_HINT_AUDIO_ALSA_DEFAULT_DEVICE);
         if (device) {
             return device;
         } else if (channels == 6) {