From 144240717ddaac25c5a1072aae17831ce6dc6671 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 14 May 2009 18:51:53 +0000 Subject: [PATCH] Don't turn mixer channel off is current volume is not 0. Slowly decrease volume if idle for a while. Fixes (most of) the clicks of secret agent. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3387 --- src/hardware/pcspeaker.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/hardware/pcspeaker.cpp b/src/hardware/pcspeaker.cpp index 1e063e7e..15b5887b 100644 --- a/src/hardware/pcspeaker.cpp +++ b/src/hardware/pcspeaker.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - /* $Id: pcspeaker.cpp,v 1.24 2007-07-15 16:36:27 c2woody Exp $ */ + /* $Id: pcspeaker.cpp,v 1.25 2009-05-14 18:51:53 qbix79 Exp $ */ #include #include "dosbox.h" @@ -305,15 +305,21 @@ static void PCSPEAKER_CallBack(Bitu len) { if(spkr.chan) spkr.chan->AddSamples_m16(len,(Bit16s*)MixTemp); //Turn off speaker after 10 seconds of idle or one second idle when in off mode + bool turnoff = false; Bitu test_ticks = PIC_Ticks; - if ((spkr.last_ticks+10000)Enable(false); + if ((spkr.last_ticks + 10000) < test_ticks) turnoff = true; + if((spkr.mode == SPKR_OFF) && ((spkr.last_ticks + 1000) < test_ticks)) turnoff = true; + + if(turnoff){ + if(spkr.volwant == 0) { + spkr.last_ticks = 0; + if(spkr.chan) spkr.chan->Enable(false); + } else { + if(spkr.volwant > 0) spkr.volwant--; else spkr.volwant++; + + } } - if((spkr.mode == SPKR_OFF) && ((spkr.last_ticks+1000) Enable(false); - } + } class PCSPEAKER:public Module_base { private: