SDL: audio: Fixed GetFirstAudioDeviceAdded().

From 759cdf6159d8aab8bcfb129d9733821ca0206938 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 1 Nov 2023 00:39:51 -0400
Subject: [PATCH] audio: Fixed GetFirstAudioDeviceAdded().

It forgot to check for the type of device needed.
---
 src/audio/SDL_audio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index a46f4efa5390..bb6acbe2bffb 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -761,9 +761,11 @@ static SDL_AudioDevice *GetFirstAddedAudioDevice(const SDL_bool iscapture)
     void *iter = NULL;
     while (SDL_IterateHashTable(current_audio.device_hash, &key, &value, &iter)) {
         const SDL_AudioDeviceID devid = (SDL_AudioDeviceID) (uintptr_t) key;
+        // bit #0 of devid is set for output devices and unset for capture.
         // bit #1 of devid is set for physical devices and unset for logical.
-        const SDL_bool isphysical = (devid & (1<<1)) ? SDL_TRUE : SDL_FALSE;
-        if (isphysical && (devid < highest)) {
+        const SDL_bool devid_iscapture = (devid & (1 << 0)) ? SDL_FALSE : SDL_TRUE;
+        const SDL_bool isphysical = (devid & (1 << 1)) ? SDL_TRUE : SDL_FALSE;
+        if (isphysical && (devid_iscapture == iscapture) && (devid < highest)) {
             highest = devid;
             retval = (SDL_AudioDevice *) value;
         }