Skip to content

Commit 157429f

Browse files
authored
Merge pull request #2135 from jepler/audio-stuttering-background
Reduce audio stuttering by running background tasks
2 parents 3422e53 + 523025c commit 157429f

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

py/obj.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ const char *mp_obj_get_type_str(mp_const_obj_t o_in) {
6363
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
6464
// There can be data structures nested too deep, or just recursive
6565
MP_STACK_CHECK();
66+
#ifdef RUN_BACKGROUND_TASKS
67+
RUN_BACKGROUND_TASKS;
68+
#endif
6669
#ifndef NDEBUG
6770
if (o_in == MP_OBJ_NULL) {
6871
mp_print_str(print, "(nil)");

py/stream.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ STATIC mp_obj_t stream_readall(mp_obj_t self_in) {
341341
p = vstr_extend(&vstr, DEFAULT_BUFFER_SIZE);
342342
current_read = DEFAULT_BUFFER_SIZE;
343343
}
344+
#ifdef RUN_BACKGROUND_TASKS
345+
RUN_BACKGROUND_TASKS;
346+
#endif
344347
}
345348

346349
vstr.len = total_size;

shared-module/os/__init__.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ mp_obj_t common_hal_os_listdir(const char* path) {
128128
while ((next = mp_iternext(iter_obj)) != MP_OBJ_STOP_ITERATION) {
129129
// next[0] is the filename.
130130
mp_obj_list_append(dir_list, mp_obj_subscr(next, MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_SENTINEL));
131+
RUN_BACKGROUND_TASKS;
131132
}
132133
return dir_list;
133134
}

0 commit comments

Comments
 (0)