From 73140c7da75eae814c470c82a49c1a57d207032e Mon Sep 17 00:00:00 2001 From: skidau Date: Fri, 11 Jan 2013 23:06:20 +1100 Subject: [PATCH] Skipped timestretching if the emulator is running below 10% speed to prevent buffer overflows. --- Source/Core/AudioCommon/Src/OpenALStream.cpp | 5 ++++- Source/Core/AudioCommon/Src/OpenALStream.h | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp index 1895cd2199..eefc62e346 100644 --- a/Source/Core/AudioCommon/Src/OpenALStream.cpp +++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp @@ -207,7 +207,10 @@ void OpenALStream::SoundLoop() Core::RequestRefreshInfo(); rate = m_mixer->GetCurrentSpeed(); } - if (rate > 0) + + // Place a lower limit of 10% speed. When a game boots up, there will be + // many silence samples. These do not need to be timestretched. + if (rate > 0.10) { // Adjust SETTING_SEQUENCE_MS to balance between lag vs hollow audio soundTouch.setSetting(SETTING_SEQUENCE_MS, (int)(1 / (rate * rate))); diff --git a/Source/Core/AudioCommon/Src/OpenALStream.h b/Source/Core/AudioCommon/Src/OpenALStream.h index b342e0a49e..f325d6b63a 100644 --- a/Source/Core/AudioCommon/Src/OpenALStream.h +++ b/Source/Core/AudioCommon/Src/OpenALStream.h @@ -73,7 +73,6 @@ public: private: std::thread thread; Common::Event soundSyncEvent; - Common::Event mainSyncEvent; short realtimeBuffer[OAL_MAX_SAMPLES * 2]; soundtouch::SAMPLETYPE sampleBuffer[OAL_MAX_SAMPLES * SIZE_FLOAT * SURROUND_CHANNELS * OAL_NUM_BUFFERS];