shithub: choc

Download patch

ref: 0ab82301d054452d319f0a23b7aeaf10270da60a
parent: 5082a2f1b43736e24e9927c16268788506b3b25b
parent: 796abf07141ade4d1c035d33bb478356a087279d
author: Fabian Greffrath <[email protected]>
date: Fri Jan 14 03:31:37 EST 2022

Merge pull request #1430 from rfomin/pause

win midi: Proper pause/resume

--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -341,9 +341,13 @@
         return;
     }
 
+#if defined(_WIN32)
+    I_WIN_PauseSong();
+#else
     musicpaused = true;
 
     UpdateMusicVolume();
+#endif
 }
 
 static void I_SDL_ResumeSong(void)
@@ -353,9 +357,13 @@
         return;
     }
 
+#if defined(_WIN32)
+    I_WIN_ResumeSong();
+#else
     musicpaused = false;
 
     UpdateMusicVolume();
+#endif
 }
 
 static void I_SDL_StopSong(void)
--- a/src/i_winmusic.c
+++ b/src/i_winmusic.c
@@ -444,6 +444,28 @@
     UpdateVolume();
 }
 
+void I_WIN_PauseSong(void)
+{
+    MMRESULT mmr;
+
+    mmr = midiStreamPause(hMidiStream);
+    if (mmr != MMSYSERR_NOERROR)
+    {
+        MidiErrorMessageBox(mmr);
+    }
+}
+
+void I_WIN_ResumeSong(void)
+{
+    MMRESULT mmr;
+
+    mmr = midiStreamRestart(hMidiStream);
+    if (mmr != MMSYSERR_NOERROR)
+    {
+        MidiErrorMessageBox(mmr);
+    }
+}
+
 boolean I_WIN_RegisterSong(char *filename)
 {
     int i;
@@ -517,6 +539,7 @@
     MMRESULT mmr;
 
     I_WIN_StopSong();
+    I_WIN_UnRegisterSong();
 
     mmr = midiOutUnprepareHeader((HMIDIOUT)hMidiStream, hdr, sizeof(MIDIHDR));
     if (mmr != MMSYSERR_NOERROR)
--- a/src/i_winmusic.h
+++ b/src/i_winmusic.h
@@ -23,6 +23,8 @@
 
 boolean I_WIN_InitMusic(void);
 void I_WIN_PlaySong(boolean looping);
+void I_WIN_PauseSong(void);
+void I_WIN_ResumeSong(void);
 void I_WIN_StopSong(void);
 void I_WIN_SetMusicVolume(int volume);
 boolean I_WIN_RegisterSong(char* filename);