From 301ee21f33c7e2cef4a0c484640fb028378a2fc5 Mon Sep 17 00:00:00 2001 From: ds-sloth <72112344+ds-sloth@users.noreply.github.com> Date: Tue, 24 Oct 2023 19:11:41 -0400 Subject: [PATCH] n3ds systhread - prefer to put audio thread on system core --- src/thread/n3ds/SDL_systhread.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/thread/n3ds/SDL_systhread.c b/src/thread/n3ds/SDL_systhread.c index 4dfb8fc49..0f633d327 100644 --- a/src/thread/n3ds/SDL_systhread.c +++ b/src/thread/n3ds/SDL_systhread.c @@ -49,15 +49,22 @@ static void ThreadEntry(void *arg) int SDL_SYS_CreateThread(SDL_Thread *thread) { - s32 priority; + s32 priority = 0x30; + int cpu = -1; size_t stack_size = GetStackSize(thread->stacksize); + svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); + /* prefer putting audio thread on system core */ + if (thread->name && SDL_strcmp(thread->name, "SDLAudioP") == 0 && R_SUCCEEDED(APT_SetAppCpuTimeLimit(30))) { + cpu = 1; + } + thread->handle = threadCreate(ThreadEntry, thread, stack_size, priority, - -1, + cpu, false); if (thread->handle == NULL) {