Skip to content

Commit e6f7833

Browse files
Fix I2S::read/write(buffer, cnt) to return bytes (#3086)
::write and ::read should always return the number of bytes processed, but we were only returing the ARB result which is *words* written. Adjust the outputs to be correct.
1 parent e2a45e6 commit e6f7833

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/I2S/src/I2S.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,15 +568,15 @@ size_t I2S::read(uint8_t *buffer, size_t size) {
568568
if (size & 0x3 || !_running || !_isInput) {
569569
return 0;
570570
}
571-
return _arbInput->read((uint32_t *)buffer, size / sizeof(uint32_t), false);
571+
return 4 * _arbInput->read((uint32_t *)buffer, size / sizeof(uint32_t), false);
572572
}
573573

574574
size_t I2S::write(const uint8_t *buffer, size_t size) {
575575
// We can only write 32-bit chunks here
576576
if (size & 0x3 || !_running || !_isOutput) {
577577
return 0;
578578
}
579-
return _arbOutput->write((const uint32_t *)buffer, size / sizeof(uint32_t), false);
579+
return 4 * _arbOutput->write((const uint32_t *)buffer, size / sizeof(uint32_t), false);
580580
}
581581

582582
int I2S::availableForWrite() {

0 commit comments

Comments
 (0)