From 7bd07e5b36007558dfd8afae56492dbb5e66f513 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sun, 29 Dec 2024 16:12:52 -0800 Subject: [PATCH] Properly wrap AudioBufferManager block writes The memcpy-version of the ABM::write updated the destination and count but neglected to move the source forward. If a block write crossed a frame boundary then the 2nd frame would repeat the data from the first half of the buffer. Fix by incrementing the source pointer by the same amount as was written. --- libraries/AudioBufferManager/src/AudioBufferManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/AudioBufferManager/src/AudioBufferManager.cpp b/libraries/AudioBufferManager/src/AudioBufferManager.cpp index a2a93b3a3..bc8ee8e3c 100644 --- a/libraries/AudioBufferManager/src/AudioBufferManager.cpp +++ b/libraries/AudioBufferManager/src/AudioBufferManager.cpp @@ -209,6 +209,7 @@ size_t AudioBufferManager::write(const uint32_t *v, size_t words, bool sync) { size_t availToWriteThisBuff = _wordsPerBuffer - _userOff; size_t toWrite = std::min(availToWriteThisBuff, words); memcpy(&((*p)->buff[_userOff]), v, toWrite * sizeof(uint32_t)); + v += toWrite; written += toWrite; _userOff += toWrite; words -= toWrite;