Skip to content

Commit 22fe20b

Browse files
committed
codal_port/modaudio: Increas "used_size" when data is written.
Signed-off-by: Damien George <[email protected]>
1 parent 60bb5bf commit 22fe20b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/codal_port/modaudio.c

+5
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ STATIC mp_obj_t audio_frame_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t
368368
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
369369
}
370370
self->data[index] = value;
371+
self->used_size = MAX(self->used_size, index + 1);
371372
return mp_const_none;
372373
}
373374
}
@@ -388,6 +389,10 @@ static mp_int_t audio_frame_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufin
388389
bufinfo->buf = self->data;
389390
bufinfo->len = self->alloc_size;
390391
bufinfo->typecode = 'b';
392+
if (flags == MP_BUFFER_WRITE) {
393+
// Assume that writing to the buffer will make all data valid for playback.
394+
self->used_size = self->alloc_size;
395+
}
391396
return 0;
392397
}
393398

0 commit comments

Comments
 (0)