From f1fd371db7347cc48eb7ae6f449ff9742a6feea5 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Tue, 3 Nov 2020 20:19:21 +0000 Subject: [PATCH] Update 3DS-Software threading priority code This matches the 3DS-Hardware backend --- src/Backends/Audio/SoftwareMixer/3DS.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Backends/Audio/SoftwareMixer/3DS.cpp b/src/Backends/Audio/SoftwareMixer/3DS.cpp index 2cded36f..a8fd1a3e 100644 --- a/src/Backends/Audio/SoftwareMixer/3DS.cpp +++ b/src/Backends/Audio/SoftwareMixer/3DS.cpp @@ -14,6 +14,8 @@ #define FRAMES_PER_BUFFER (SAMPLE_RATE / 30) // 33.333 milliseconds #define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define CLAMP(a, min, max) MIN(MAX((a), (min)), (max)) static void (*parent_callback)(long *stream, size_t frames_total); @@ -134,9 +136,11 @@ unsigned long SoftwareMixerBackend_Init(void (*callback)(long *stream, size_t fr LightEvent_Init(&audio_thread_event, RESET_ONESHOT); - audio_thread_die = false; + s32 priority = 0x30; + svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); - audio_thread = threadCreate(AudioThread, NULL, 32 * 1024, 0x18, -1, false); + audio_thread_die = false; + audio_thread = threadCreate(AudioThread, NULL, 32 * 1024, CLAMP(priority - 1, 0x18, 0x3F), -1, false); return SAMPLE_RATE; }