Skip to content

Commit

Permalink
codal_port/modaudio: Increas "used_size" when data is written.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Jan 18, 2024
1 parent c70611c commit 89e5204
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/codal_port/modaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ STATIC mp_obj_t audio_frame_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
}
self->data[index] = value;
self->used_size = MAX(self->used_size, index + 1);
return mp_const_none;
}
}
Expand All @@ -388,6 +389,10 @@ static mp_int_t audio_frame_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufin
bufinfo->buf = self->data;
bufinfo->len = self->alloc_size;
bufinfo->typecode = 'b';
if (flags == MP_BUFFER_WRITE) {
// Assume that writing to the buffer will make all data valid for playback.
self->used_size = self->alloc_size;
}
return 0;
}

Expand Down

0 comments on commit 89e5204

Please sign in to comment.