Skip to content

Commit 4878157

Browse files
committed
codal_port/modaudio: Increas "used_size" when data is written.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 40979ac commit 4878157

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/codal_port/modaudio.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ static mp_obj_t audio_frame_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t
354354
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
355355
}
356356
self->data[index] = value;
357+
self->used_size = MAX(self->used_size, index + 1);
357358
return mp_const_none;
358359
}
359360
}
@@ -374,6 +375,10 @@ static mp_int_t audio_frame_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufin
374375
bufinfo->buf = self->data;
375376
bufinfo->len = self->alloc_size;
376377
bufinfo->typecode = 'b';
378+
if (flags == MP_BUFFER_WRITE) {
379+
// Assume that writing to the buffer will make all data valid for playback.
380+
self->used_size = self->alloc_size;
381+
}
377382
return 0;
378383
}
379384

0 commit comments

Comments
 (0)