From f6cb29ca1c6ec05a873b94790398312f12491237 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 14 Aug 2008 07:34:42 +0000 Subject: [PATCH] zeromus - SF [ 2047001 ] Low speeds crash FCEUX this was caused by a bug in the sound engine which overflowed when things got too slow. the instability at low speeds and turboing is not in the emulation but rather in the rather clumsy resynchronization code in the sound engine. this needs work, but the badness should be harmless. --- changelog.txt | 1 + src/drivers/win/sound.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 7285091a..4b9390a7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,6 @@ ---version 2.0.2 released--- +14-aug-2008 - zeromus - SF [ 2047001 ] Low speeds crash FCEUX 14-aug-2008 - zeromus - SF [ 2050371 ] FCM>FM2 converter should release file handle 13-aug-2008 - zeromus - restore ungzipping (and unzipping in sdl) capability which was lost when archive support was added 13-aug-2008 - zeromus - add FORBID breakpoints - regions which block breakpoints from happening if they contain the PC diff --git a/src/drivers/win/sound.cpp b/src/drivers/win/sound.cpp index e99dd702..307dee71 100644 --- a/src/drivers/win/sound.cpp +++ b/src/drivers/win/sound.cpp @@ -165,16 +165,20 @@ public: //not interpolating! someday it will! int generate(int samples, void *buf) { - int incr = 256; - int bufferSamples = buffers.length>>1; + int64 incr = 256; + int64 bufferSamples = buffers.length>>1; //if we're we're too far behind, playback faster if(bufferSamples > soundrate*3/60) { - int behind = bufferSamples - soundrate/60; + int64 behind = bufferSamples - soundrate/60; incr = behind*256*60/soundrate/2; //we multiply our playback rate by 1/2 the number of frames we're behind } - if(incr<256) printf("OHNO -- %d -- shouldnt be less than 256!\n",incr); //sanity check: should never be less than 256 + if(incr<256) + { + //sanity check: should never be less than 256 + printf("OHNO -- %d -- shouldnt be less than 256!\n",incr); + } incr = (incr*scale)>>8; //apply scaling factor