Skip to content

Commit

Permalink
Fix I2S::write(const uint8_t *buffer, size_t size) (#1461)
Browse files Browse the repository at this point in the history
According to this: #1450
  • Loading branch information
LinusHeu committed May 20, 2023
1 parent a1ae61b commit 3b4fb29
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions libraries/I2S/src/I2S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,14 @@ bool I2S::read32(int32_t *l, int32_t *r) {

size_t I2S::write(const uint8_t *buffer, size_t size) {
// We can only write 32-bit chunks here
if (size & 0x3) {
if (size & 0x3 || !_running || !_isOutput) {
return 0;
}

size_t writtenSize = 0;
int32_t *p = (int32_t *)buffer;
uint32_t *p = (uint32_t *)buffer;
while (size) {
if (!write((int32_t)*p)) {
if (!_arb->write(*p, false)) {
// Blocked, stop write here
return writtenSize;
} else {
Expand Down

0 comments on commit 3b4fb29

Please sign in to comment.