Skip to content

Commit 19d122e

Browse files
committed
nrf: i2sout: Fix double-increment when copying samples
This caused two problems when playing unsigned samples: * When an even number of samples were present, it "worked" but only every other sample was copied into the output, changing the waveform * When an odd number of samples were present, the copy continued beyond the end of the buffers and caused a hard fault
1 parent c000567 commit 19d122e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ports/nrf/common-hal/audiobusio/I2SOut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ static void i2s_buffer_fill(audiobusio_i2sout_obj_t* self) {
139139
uint16_t *bp = (uint16_t*)buffer;
140140
uint16_t *be = (uint16_t*)(buffer + bytecount);
141141
uint16_t *sp = (uint16_t*)self->sample_data;
142-
for (; bp != be; bp++) {
142+
for (; bp != be;) {
143143
*bp++ = *sp++ + 0x8000;
144144
}
145145
} else {
146146
uint8_t *bp = (uint8_t*)buffer;
147147
uint8_t *be = (uint8_t*)(buffer + bytecount);
148148
uint8_t *sp = (uint8_t*)self->sample_data;
149-
for (; bp != be; bp++) {
149+
for (; bp != be;) {
150150
*bp++ = *sp++ + 0x80;
151151
}
152152
}

0 commit comments

Comments
 (0)