SDL: Removed unused code

From ea5f59c234dca9f4e47f699babaf3f9130639734 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 27 Sep 2023 09:16:25 -0700
Subject: [PATCH] Removed unused code

It looks like we don't need to watch for hanging writes now that we're using the callback mechanism.
---
 src/audio/aaudio/SDL_aaudio.c         | 31 ---------------------------
 src/audio/aaudio/SDL_aaudio.h         |  2 --
 src/video/android/SDL_androidevents.c | 10 ---------
 3 files changed, 43 deletions(-)

diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c
index f6cf88e02a7d..0e08156d0487 100644
--- a/src/audio/aaudio/SDL_aaudio.c
+++ b/src/audio/aaudio/SDL_aaudio.c
@@ -408,37 +408,6 @@ void AAUDIO_ResumeDevices(void)
     }
 }
 
-// !!! FIXME: do we need this now that we use the callback?
-/*
- We can sometimes get into a state where AAudioStream_write() will just block forever until we pause and unpause.
- None of the standard state queries indicate any problem in my testing. And the error callback doesn't actually get called.
- But, AAudioStream_getTimestamp() does return AAUDIO_ERROR_INVALID_STATE
-*/
-static SDL_bool DetectBrokenPlayStatePerDevice(SDL_AudioDevice *device, void *userdata)
-{
-    SDL_assert(device != NULL);
-    if (!device->iscapture && device->hidden != NULL) {
-        struct SDL_PrivateAudioData *hidden = device->hidden;
-        int64_t framePosition, timeNanoseconds;
-        aaudio_result_t res = ctx.AAudioStream_getTimestamp(hidden->stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds);
-        if (res == AAUDIO_ERROR_INVALID_STATE) {
-            aaudio_stream_state_t currentState = ctx.AAudioStream_getState(hidden->stream);
-            // AAudioStream_getTimestamp() will also return AAUDIO_ERROR_INVALID_STATE while the stream is still initially starting. But we only care if it silently went invalid while playing.
-            if (currentState == AAUDIO_STREAM_STATE_STARTED) {
-                LOGI("SDL AAUDIO_DetectBrokenPlayState: detected invalid audio device state: AAudioStream_getTimestamp result=%d, framePosition=%lld, timeNanoseconds=%lld, getState=%d", (int)res, (long long)framePosition, (long long)timeNanoseconds, (int)currentState);
-                return SDL_TRUE;  // this guy.
-            }
-        }
-    }
-
-    return SDL_FALSE;  // enumerate more devices.
-}
-
-SDL_bool AAUDIO_DetectBrokenPlayState(void)
-{
-    return (ctx.handle && SDL_FindPhysicalAudioDeviceByCallback(DetectBrokenPlayStatePerDevice, NULL) != NULL) ? SDL_TRUE : SDL_FALSE;
-}
-
 static void AAUDIO_Deinitialize(void)
 {
     Android_StopAudioHotplug();
diff --git a/src/audio/aaudio/SDL_aaudio.h b/src/audio/aaudio/SDL_aaudio.h
index 137dd8157708..b866f2ede525 100644
--- a/src/audio/aaudio/SDL_aaudio.h
+++ b/src/audio/aaudio/SDL_aaudio.h
@@ -27,13 +27,11 @@
 
 void AAUDIO_ResumeDevices(void);
 void AAUDIO_PauseDevices(void);
-SDL_bool AAUDIO_DetectBrokenPlayState(void);
 
 #else
 
 #define AAUDIO_ResumeDevices()
 #define AAUDIO_PauseDevices()
-#define AAUDIO_DetectBrokenPlayState() (SDL_FALSE)
 
 #endif
 
diff --git a/src/video/android/SDL_androidevents.c b/src/video/android/SDL_androidevents.c
index 8dbe13ddb98c..ff39d801c776 100644
--- a/src/video/android/SDL_androidevents.c
+++ b/src/video/android/SDL_androidevents.c
@@ -159,11 +159,6 @@ void Android_PumpEvents_Blocking(SDL_VideoDevice *_this)
             }
         }
     }
-
-    if (AAUDIO_DetectBrokenPlayState()) {
-        AAUDIO_PauseDevices();
-        AAUDIO_ResumeDevices();
-    }
 }
 
 void Android_PumpEvents_NonBlocking(SDL_VideoDevice *_this)
@@ -245,11 +240,6 @@ void Android_PumpEvents_NonBlocking(SDL_VideoDevice *_this)
             }
         }
     }
-
-    if (AAUDIO_DetectBrokenPlayState()) {
-        AAUDIO_PauseDevices();
-        AAUDIO_ResumeDevices();
-    }
 }
 
 #endif /* SDL_VIDEO_DRIVER_ANDROID */