From 4c3d727ad0001cf02683097a807de9d2d4753845 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 13 Jan 2021 12:47:09 -0500 Subject: [PATCH] fix for rare crash --- src/sound.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sound.cpp b/src/sound.cpp index ac27188f..e17dae72 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -564,9 +564,10 @@ void FCEU_SoundCPUHook(int cycles) /* Unbelievably ugly hack */ if(FSettings.SndRate) { - soundtsoffs+=DMCacc; - DoPCM(); - soundtsoffs-=DMCacc; + const uint32 fudge = std::min(-DMCacc, soundtsoffs + timestamp); + soundtsoffs -= fudge; + DoPCM(); + soundtsoffs += fudge; } RawDALatch+=t; if(RawDALatch&0x80)