SDL_native_midi: Update SDL_native_midi_macos.c

From bd8502946727416c6e280bb43d4ee26705138d59 Mon Sep 17 00:00:00 2001
From: Mark Kunka <[EMAIL REDACTED]>
Date: Wed, 25 Jun 2025 17:17:16 -0700
Subject: [PATCH] Update SDL_native_midi_macos.c

---
 src/SDL_native_midi_macos.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/SDL_native_midi_macos.c b/src/SDL_native_midi_macos.c
index a45889c..556e7cb 100644
--- a/src/SDL_native_midi_macos.c
+++ b/src/SDL_native_midi_macos.c
@@ -274,8 +274,18 @@ void NativeMidi_DestroySong(NativeMidi_Song *song)
     }
 }
 
+static NativeMidi_Song* paused_song = NULL;
+static MusicTimeStamp paused_time = 0;
+static bool resume = false;
+
 void NativeMidi_Start(NativeMidi_Song *song, int loops)
 {
+    if (!resume) {
+        // If we are not resuming a paused song, clear any existing paused info.
+        paused_song = NULL;
+        paused_time = 0;
+    }
+
     if (song) {
         if (currentsong) {
             MusicPlayerStop(currentsong->player);
@@ -294,17 +304,29 @@ void NativeMidi_Start(NativeMidi_Song *song, int loops)
         latched_volume += 1.0f;  // +1 just make this not match.
         NativeMidi_SetVolume(vol);
 
-        MusicPlayerSetTime(song->player, 0);
+        MusicPlayerSetTime(song->player, resume ? paused_time : 0);
         MusicPlayerStart(song->player);
     }
 }
 
 void NativeMidi_Pause(void)
 {
+    if (currentsong) {
+        paused_song = currentsong;
+        MusicPlayerGetTime(currentsong->player, &paused_time);
+        NativeMidi_Stop();
+    }
 }
 
 void NativeMidi_Resume(void)
 {
+    if (paused_song) {
+        resume = true;
+        NativeMidi_Start(paused_song, paused_song->loops);
+        paused_song = NULL;
+        paused_time = 0;
+        resume = false;
+    }
 }
 
 void NativeMidi_Stop(void)