diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-01-30 15:52:54 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-01-30 15:52:54 +1100 |
| commit | ef8d404b15e6d32506617a95aa3161fbe59ecdaf (patch) | |
| tree | f05d5f0a81b1477846e85bf44f0154db015b9789 /src/audio/chunk.cpp | |
| parent | 2cc0a38a1ac7fc54d7333dafa8b99479a7f5dc86 (diff) | |
| download | tangara-fw-ef8d404b15e6d32506617a95aa3161fbe59ecdaf.tar.gz | |
Continue ironing out i2s pipeline
still at least one heap corruption issue, plus the i2s write method
seems to block forever :/
Diffstat (limited to 'src/audio/chunk.cpp')
| -rw-r--r-- | src/audio/chunk.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/audio/chunk.cpp b/src/audio/chunk.cpp index baf2aba5..fb7f1354 100644 --- a/src/audio/chunk.cpp +++ b/src/audio/chunk.cpp @@ -25,6 +25,7 @@ ChunkReader::~ChunkReader() { auto ChunkReader::HandleNewData(cpp::span<std::byte> data) -> cpp::span<std::byte> { + assert(leftover_bytes_ + data.size() <= working_buffer_.size()); // Copy the new data onto the front for anything that was left over from the // last portion. Note: this could be optimised for the '0 leftover bytes' // case, which technically shouldn't need a copy. @@ -40,10 +41,8 @@ auto ChunkReader::HandleLeftovers(std::size_t bytes_used) -> void { leftover_bytes_ = last_data_in_working_buffer_.size() - bytes_used; if (leftover_bytes_ > 0) { auto data_to_keep = last_data_in_working_buffer_.last(leftover_bytes_); - // Copy backwards, since if more than half of the data was unused then the - // source and destination will overlap. - std::copy_backward(data_to_keep.begin(), data_to_keep.end(), - working_buffer_.begin()); + std::copy(data_to_keep.begin(), data_to_keep.end(), + working_buffer_.begin()); } } |
