Skip to content

Commit 60bb5bf

Browse files
committed
codal_port/modaudio: Round up AudioFrame size to nearest 32.
Signed-off-by: Damien George <[email protected]>
1 parent 5e13c27 commit 60bb5bf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: src/codal_port/modaudio.c

+2
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ STATIC mp_obj_t microbit_audio_frame_new(const mp_obj_type_t *type_in, size_t n_
343343
mp_raise_ValueError(MP_ERROR_TEXT("size out of bounds"));
344344
} else {
345345
size = args[ARG_duration].u_int * rate / 1000;
346+
// Round up the size to the nearest AUDIO_CHUNK_SIZE.
347+
size = (size + AUDIO_CHUNK_SIZE - 1) & ~(AUDIO_CHUNK_SIZE - 1);
346348
}
347349

348350
return microbit_audio_frame_make_new(size, rate);

0 commit comments

Comments
 (0)