SDL: Fixed crash when we can't recover the audio device under OpenHarmony

From 772072a8e3aeab96b7c1bc7aaefd6d5b2d4e0a05 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 12 Oct 2026 18:29:43 -0700
Subject: [PATCH] Fixed crash when we can't recover the audio device under
 OpenHarmony

---
 src/audio/ohaudio/SDL_ohaudio.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/audio/ohaudio/SDL_ohaudio.c b/src/audio/ohaudio/SDL_ohaudio.c
index ec36bcb038594..d854bf433a607 100644
--- a/src/audio/ohaudio/SDL_ohaudio.c
+++ b/src/audio/ohaudio/SDL_ohaudio.c
@@ -254,6 +254,10 @@ static bool RecoverOHAudioDevice(SDL_AudioDevice *device)
     SDL_copyp(&prevspec, &device->spec);
 
     if (!BuildOHAudioStream(device)) {
+        // Restore the buffer sizes that match the allocated buffers, so we don't crash
+        device->sample_frames = prev_sample_frames;
+        SDL_copyp(&device->spec, &prevspec);
+        SDL_UpdatedAudioDeviceFormat(device);
         return false;  // oh well, we tried.
     }