Skip to content

Commit 40979ac

Browse files
committed
codal_port/modaudio: Round up AudioFrame size to nearest 32.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 4e3ac1d commit 40979ac

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/codal_port/modaudio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ static mp_obj_t microbit_audio_frame_new(const mp_obj_type_t *type_in, size_t n_
329329
mp_raise_ValueError(MP_ERROR_TEXT("size out of bounds"));
330330
} else {
331331
size = args[ARG_duration].u_int * rate / 1000;
332+
// Round up the size to the nearest AUDIO_CHUNK_SIZE.
333+
size = (size + AUDIO_CHUNK_SIZE - 1) & ~(AUDIO_CHUNK_SIZE - 1);
332334
}
333335

334336
return microbit_audio_frame_make_new(size, rate);

0 commit comments

Comments
 (0)