From 16809ab9f432e902b4b049b4f1f01a0f42e92914 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 6 Jul 2023 18:47:31 +0300 Subject: [PATCH] libretro: disable spu thread by default, with option to reenable it may still cause problems, especially with reverb, fixing it is too much work for too little benefit --- frontend/libretro.c | 10 ++++++++++ frontend/libretro_core_options.h | 16 ++++++++++++++++ frontend/main.c | 3 ++- plugins/dfsound/spu.c | 3 +-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index 3e74b230..f4b23cdf 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2074,6 +2074,16 @@ static void update_variables(bool in_flight) spu_config.iUseInterpolation = 0; } + var.value = NULL; + var.key = "pcsx_rearmed_spu_thread"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + spu_config.iUseThread = 1; + else + spu_config.iUseThread = 0; + } + #ifndef _WIN32 var.value = NULL; var.key = "pcsx_rearmed_async_cd"; diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 935c6f97..7d070f9a 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -752,6 +752,22 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "enabled", }, +#if !defined(THREAD_ENABLED) && !defined(_WIN32) && !defined(NO_OS) + { + "pcsx_rearmed_spu_thread", + "Threaded SPU", + NULL, + "Emulates the PSX SPU on another CPU thread. May cause audio glitches in some games.", + NULL, + "audio", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled", + }, +#endif // THREAD_ENABLED { "pcsx_rearmed_show_input_settings", "Show Input Settings", diff --git a/frontend/main.c b/frontend/main.c index 2773f7a1..e0635ef4 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -158,7 +158,8 @@ void emu_set_default_config(void) spu_config.iXAPitch = 0; spu_config.iVolume = 768; spu_config.iTempo = 0; - spu_config.iUseThread = 1; // no effect if only 1 core is detected + // may cause issues, no effect if only 1 core is detected + spu_config.iUseThread = 0; #if defined(HAVE_PRE_ARMV7) && !defined(_3DS) /* XXX GPH hack */ spu_config.iUseReverb = 0; spu_config.iUseInterpolation = 0; diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 97f07aae..ebebd2a2 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -18,8 +18,7 @@ * * ***************************************************************************/ -#if !defined(_WIN32) && !defined(NO_OS) -#include // gettimeofday in xa.c +#if !defined(THREAD_ENABLED) && !defined(_WIN32) && !defined(NO_OS) #define THREAD_ENABLED 1 #endif #include "stdafx.h" -- 2.39.5