Skip to content

Commit 216374c

Browse files
committed
Fix audiocore.RawSample with loop=False on esp32*
We only want to exit the playing loop when the sample_data wasn't null, otherwise we need to get the buffer and play it once. Fix adafruit#10539
1 parent 234ebf4 commit 216374c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ports/espressif/common-hal/audiobusio/__init__.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ static void i2s_fill_buffer(i2s_t *self) {
4242
while (!self->stopping && output_buffer_size > 0) {
4343
if (self->sample_data == self->sample_end) {
4444
uint32_t sample_buffer_length;
45+
uint8_t *old_sample_data = self->sample_data;
4546
audioio_get_buffer_result_t get_buffer_result =
4647
audiosample_get_buffer(self->sample, false, 0,
4748
&self->sample_data, &sample_buffer_length);
4849
self->sample_end = self->sample_data + sample_buffer_length;
4950
if (get_buffer_result == GET_BUFFER_DONE) {
5051
if (self->loop) {
5152
audiosample_reset_buffer(self->sample, false, 0);
52-
} else {
53+
} else if (old_sample_data) {
5354
self->stopping = true;
5455
break;
5556
}

0 commit comments

Comments
 (0)