From b1e31d89e15529beba225a8855c27ee04b3c0be6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 10 Oct 2021 15:04:59 -0700 Subject: [PATCH] Audio: Correct protection against time skew. --- Core/HW/StereoResampler.cpp | 2 +- UI/BackgroundAudio.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HW/StereoResampler.cpp b/Core/HW/StereoResampler.cpp index 3f0f973a0b92..1a8a033821a9 100644 --- a/Core/HW/StereoResampler.cpp +++ b/Core/HW/StereoResampler.cpp @@ -283,7 +283,7 @@ void StereoResampler::PushSamples(const s32 *samples, unsigned int numSamples) { } // Check if we need to roll over to the start of the buffer during the copy. - int indexW_left_samples = m_maxBufsize * 2 - (indexW & INDEX_MASK); + unsigned int indexW_left_samples = m_maxBufsize * 2 - (indexW & INDEX_MASK); if (numSamples * 2 > indexW_left_samples) { ClampBufferToS16WithVolume(&m_buffer[indexW & INDEX_MASK], samples, indexW_left_samples); ClampBufferToS16WithVolume(&m_buffer[0], samples + indexW_left_samples, numSamples * 2 - indexW_left_samples); diff --git a/UI/BackgroundAudio.cpp b/UI/BackgroundAudio.cpp index 5db580ffcdd9..ff83abcfc519 100644 --- a/UI/BackgroundAudio.cpp +++ b/UI/BackgroundAudio.cpp @@ -345,7 +345,7 @@ int BackgroundAudio::Play() { double now = time_now_d(); int sz = 44100 / 60; - if (lastPlaybackTime_ > 0.0 && lastPlaybackTime_ >= now) { + if (lastPlaybackTime_ > 0.0 && lastPlaybackTime_ <= now) { sz = (int)((now - lastPlaybackTime_) * 44100); } sz = std::min(BUFSIZE / 2, sz);