From cc5e6d19c3a16544cbd13922c19e06da18224754 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 26 Aug 2020 04:10:16 +0200 Subject: [PATCH] - fixed sound updating by moving the engine's UpdateSound call into the main loop. This needs to be called unconditionally for every frame being rendered, not all of the game modules did that. Placing this call here ensures that it is independent of anything the games do. --- source/blood/src/sfx.cpp | 2 +- source/core/gamecontrol.cpp | 4 +++- source/exhumed/src/sound.cpp | 1 - source/exhumed/src/view.cpp | 2 -- source/games/duke/src/sounds.cpp | 1 - source/sw/src/game.cpp | 1 - source/sw/src/sounds.cpp | 1 - 7 files changed, 4 insertions(+), 8 deletions(-) diff --git a/source/blood/src/sfx.cpp b/source/blood/src/sfx.cpp index 9e6a9e4f3..7c600ed12 100644 --- a/source/blood/src/sfx.cpp +++ b/source/blood/src/sfx.cpp @@ -137,7 +137,7 @@ void sfxUpdate3DSounds(void) listener.ListenerObject = gMe->pSprite; soundEngine->SetListener(listener); - soundEngine->UpdateSounds(gameclock); + soundEngine->UpdateSounds(I_GetTime()); } FSoundID getSfx(FSoundID soundId, float &attenuation, int &pitch, int &relvol) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 85731f809..d2629ed37 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -930,9 +930,11 @@ void app_loop() if (gamestate == GS_LEVEL) DrawFullscreenBlends(); DrawRateStuff(); + soundEngine->UpdateSounds(I_GetTime()); + Mus_UpdateMusic(); // must be at the end. + videoNextPage(); videoSetBrightness(0); // immediately reset this so that the value doesn't stick around in the backend. - Mus_UpdateMusic(); // must be at the end. } catch (CRecoverableError& err) { diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index ccd3f0a24..86c62496d 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -522,7 +522,6 @@ void UpdateSounds() soundEngine->SetListener(listener); - soundEngine->UpdateSounds(I_GetTime()); soundEngine->EnumerateChannels([](FSoundChan* chan) { if (!(chan->ChanFlags & (CHANF_UI|CHANF_FORGETTABLE))) diff --git a/source/exhumed/src/view.cpp b/source/exhumed/src/view.cpp index c8cffb9b1..f2f32bdda 100644 --- a/source/exhumed/src/view.cpp +++ b/source/exhumed/src/view.cpp @@ -246,8 +246,6 @@ void DrawView(double smoothRatio, bool sceneonly) fix16_t nAngle; fix16_t pan; - UpdateSounds(); - zbob = Sin(2 * bobangle) >> 3; int nPlayerSprite = PlayerList[nLocalPlayer].nSprite; diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 59bfff35a..dfb5ef329 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -353,7 +353,6 @@ void S_Update(void) } listener.ListenerObject = ud.camerasprite == -1 ? nullptr : &sprite[ud.camerasprite]; soundEngine->SetListener(listener); - soundEngine->UpdateSounds(I_GetTime()); } diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index e78c42b2e..b0a233227 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -711,7 +711,6 @@ void EndOfLevel() COVER_SetReverb(0); // Reset reverb Player[myconnectindex].Reverb = 0; StopSound(); - soundEngine->UpdateSounds(I_GetTime()); // NextLevel must be null while the intermission is running, but we still need the value for later auto localNextLevel = NextLevel; NextLevel = nullptr; diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index 2cfd0552e..8c096a3fb 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -604,7 +604,6 @@ void DoUpdateSounds(void) soundEngine->SetListener(listener); UpdateAmbients(); - soundEngine->UpdateSounds(I_GetTime()); } //==========================================================================