From 893360150760138f88f2cd2abc2f7f0de28fc6bb Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Thu, 6 Dec 2018 07:08:18 -0500
Subject: [PATCH] DD hack to pause music during a wipe

---
 src/f_wipe.c  | 20 ++++++++++++++++++++
 src/p_setup.c |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/src/f_wipe.c b/src/f_wipe.c
index 95dd5bbdef..2ded899de8 100644
--- a/src/f_wipe.c
+++ b/src/f_wipe.c
@@ -27,6 +27,10 @@
 #include "d_main.h"
 #include "m_misc.h" // movie mode
 
+#ifdef _WINDOWS
+#include "s_sound.h" // DD music hack
+#endif
+
 #ifdef HWRENDER
 #include "hardware/hw_main.h"
 #endif
@@ -337,6 +341,16 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
 	UINT8 wipeframe = 0;
 	fademask_t *fmask;
 
+#ifdef _WINDOWS
+	boolean waspaused = false;
+	// DD HACK: Music doesn't work during wipes, so halt it before the wipe starts
+	if (S_MusicPlaying() && !S_MusicPaused())
+	{
+		S_PauseAudio();
+		waspaused = true;
+	}
+#endif
+
 	paldiv = FixedDiv(257<<FRACBITS, 11<<FRACBITS);
 
 	// Init the wipe
@@ -375,5 +389,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu)
 			M_SaveFrame();
 	}
 	WipeInAction = false;
+
+#ifdef _WINDOWS
+	// DD HACK: Music doesn't work during wipes, so resume it after the wipe ends
+	if (waspaused)
+		S_ResumeAudio();
+#endif
 #endif
 }
diff --git a/src/p_setup.c b/src/p_setup.c
index 93eb755831..224f9c682d 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2712,6 +2712,11 @@ boolean P_SetupLevel(boolean skipprecip)
 		tic_t endtime = starttime + (3*TICRATE)/2;
 		tic_t nowtime;
 
+#if defined(_WINDOWS)
+		// DD hack: Music doesn't work when wiping.
+		// Stop music now because we do a second wipe after a delay
+		S_StopMusic();
+#endif
 		S_StartSound(NULL, sfx_s3kaf);
 
 		F_WipeStartScreen();
-- 
GitLab