Skip to content

Commit

Permalink
Properly wrap AudioBufferManager block writes (#2725)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
earlephilhower authored Dec 30, 2024
1 parent bb682bb commit cc2581a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions libraries/AudioBufferManager/src/AudioBufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cc2581a

Please sign in to comment.