Skip to content

Commit 56b0113

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

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
@@ -357,6 +357,7 @@ STATIC mp_obj_t audio_frame_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t
357357
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
358358
}
359359
self->data[index] = value;
360+
self->used_size = MAX(self->used_size, index + 1);
360361
return mp_const_none;
361362
}
362363
}
@@ -377,6 +378,10 @@ static mp_int_t audio_frame_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufin
377378
bufinfo->buf = self->data;
378379
bufinfo->len = self->alloc_size;
379380
bufinfo->typecode = 'b';
381+
if (flags == MP_BUFFER_WRITE) {
382+
// Assume that writing to the buffer will make all data valid for playback.
383+
self->used_size = self->alloc_size;
384+
}
380385
return 0;
381386
}
382387

0 commit comments

Comments
 (0)