HLE DSP: Pop unused samples when loading new buffer

This commit is contained in:
wheremyfoodat 2024-07-29 21:58:00 +03:00
parent c7db6fe5dc
commit 45dd69d62a

View file

@ -2,6 +2,7 @@
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <iterator>
#include <thread> #include <thread>
#include <utility> #include <utility>
@ -370,6 +371,13 @@ namespace Audio {
break; break;
} }
// We're skipping the first samplePosition samples, so remove them from the buffer so as not to consume them later
if (source.samplePosition > 0) {
auto start = source.currentSamples.begin();
auto end = std::next(start, source.samplePosition);
source.currentSamples.erase(start, end);
}
// If the buffer is a looping buffer, re-push it // If the buffer is a looping buffer, re-push it
if (buffer.looping) { if (buffer.looping) {
source.pushBuffer(buffer); source.pushBuffer(buffer);