From: notaz Date: Sun, 15 Mar 2026 23:55:15 +0000 (+0200) Subject: spu: use USE_ASYNC_ like the other threaded parts X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d3a7ad2c4a7445b1745435a246e2cee0ae492ce;p=pcsx_rearmed.git spu: use USE_ASYNC_ like the other threaded parts also drop no longer used P_HAVE_PTHREAD --- diff --git a/Makefile b/Makefile index c13e21ec..07f785e1 100644 --- a/Makefile +++ b/Makefile @@ -75,7 +75,6 @@ LDFLAGS += $(FSECTIONS_LDFLAGS) endif endif # NO_FSECTIONS CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \ - -DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \ -DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \ -DDISABLE_MEM_LUTS=0 CXXFLAGS += $(CFLAGS) @@ -137,6 +136,11 @@ frontend/libretro.o: CFLAGS += -DUSE_ASYNC_GPU frontend/menu.o: CFLAGS += -DUSE_ASYNC_GPU USE_RTHREADS := 1 endif +ifeq "$(USE_ASYNC_SPU)" "1" +frontend/libretro.o: CFLAGS += -DUSE_ASYNC_SPU +frontend/menu.o: CFLAGS += -DUSE_ASYNC_SPU +USE_RTHREADS := 1 +endif # dynarec ifeq "$(DYNAREC)" "lightrec" @@ -236,6 +240,9 @@ ifeq "$(HAVE_C64_TOOLS)" "1" plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE frontend/menu.o: CFLAGS += -DC64X_DSP endif +ifeq "$(USE_ASYNC_SPU)" "1" +plugins/dfsound/%.o: CFLAGS += -DUSE_ASYNC_SPU +endif ifneq ($(findstring oss,$(SOUND_DRIVERS)),) plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS OBJS += plugins/dfsound/oss.o diff --git a/Makefile.libretro b/Makefile.libretro index 97813dad..52d690ff 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -6,6 +6,7 @@ HAVE_CHD ?= 1 HAVE_PHYSICAL_CDROM ?= 1 USE_ASYNC_CDROM ?= 1 USE_ASYNC_GPU ?= 1 +USE_ASYNC_SPU ?= 1 USE_LIBRETRO_VFS ?= 0 NDRC_THREAD ?= 1 GNU_LINKER ?= 1 @@ -282,7 +283,6 @@ else ifeq ($(platform), libnx) CFLAGS += -ftree-vectorize CFLAGS += -Ifrontend/switch NO_POSIX_MEMALIGN := 1 - NO_PTHREAD=1 NO_MMAP := 1 # for psxmem LIBPTHREAD := WANT_ZLIB = 0 @@ -310,13 +310,13 @@ else ifeq ($(platform), psl1ght) NO_UNDEF_CHECK := 1 STATIC_LINKING := 1 NO_MMAP := 1 - NO_PTHREAD := 1 LIBPTHREAD := LIBDL := NEED_SYSCONF := 1 HAVE_PHYSICAL_CDROM = 0 USE_ASYNC_CDROM = 0 USE_ASYNC_GPU = 0 + USE_ASYNC_SPU = 0 # PSP else ifeq ($(platform), psp1) @@ -413,7 +413,6 @@ else ifneq (,$(filter $(platform),ngc wii wiiu)) CFLAGS += -DGEKKO -mcpu=750 -meabi -mhard-float CFLAGS += -DNO_DYLIB STATIC_LINKING := 1 - NO_PTHREAD := 1 NO_MMAP := 1 NO_POSIX_MEMALIGN := 1 LIBDL := @@ -422,6 +421,7 @@ else ifneq (,$(filter $(platform),ngc wii wiiu)) HAVE_PHYSICAL_CDROM = 0 USE_ASYNC_CDROM = 0 USE_ASYNC_GPU = 0 + USE_ASYNC_SPU = 0 # QNX else ifeq ($(platform), qnx) @@ -595,7 +595,6 @@ else ifeq ($(platform), miyoo) # Emscripten else ifeq ($(platform), emscripten) TARGET := $(TARGET_NAME)_libretro_$(platform).bc - pthread ?= 0 fpic := -fPIC NO_MMAP = 1 # we can use -lz for emscripten's built-in zlib port @@ -603,24 +602,11 @@ else ifeq ($(platform), emscripten) CFLAGS_OPT = -O2 CFLAGS += -DNO_DYLIB -DNO_SOCKET CFLAGS += -msimd128 -ftree-vectorize - # when compiling with pthreads... - ifneq ($(pthread), 0) - # use -lpthread - LIBPTHREAD := -lpthread - NO_PTHREAD=0 - # but we don't want to include libretro-common's rthread object files here - USE_RTHREADS=0 - USE_ASYNC_CDROM=0 - USE_ASYNC_GPU=0 - # so we disable some uses of threads within pcsx_rearmed. - # is this a good solution? I don't know! - else - LIBPTHREAD := - USE_RTHREADS=0 - USE_ASYNC_CDROM=0 - USE_ASYNC_GPU=0 - NO_PTHREAD=1 - endif + LIBPTHREAD := + USE_RTHREADS=0 + USE_ASYNC_CDROM=0 + USE_ASYNC_GPU=0 + USE_ASYNC_SPU=0 DYNAREC = STATIC_LINKING = 1 HAVE_PHYSICAL_CDROM = 0 @@ -635,12 +621,12 @@ ifneq ($(DEBUG),1) endif CFLAGS += -D__WIN32__ -DNO_DYLIB MMAP_WIN32=1 - NO_PTHREAD=1 MAIN_LDLIBS += -lws2_32 LIBPTHREAD := LIBDL := LIBM := USE_LIBRETRO_VFS = 1 + USE_ASYNC_SPU = 0 # uses posix semaphore.h endif CFLAGS += $(fpic) diff --git a/configure b/configure index c0bbb6f0..b6a21509 100755 --- a/configure +++ b/configure @@ -684,6 +684,7 @@ fi if [ "$multithreading" = "yes" ]; then echo "USE_ASYNC_CDROM = 1" >> $config_mak echo "USE_ASYNC_GPU = 1" >> $config_mak + echo "USE_ASYNC_SPU = 1" >> $config_mak echo "NDRC_THREAD = 1" >> $config_mak fi diff --git a/frontend/libretro.c b/frontend/libretro.c index 32a8a9b6..22898b56 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2608,7 +2608,7 @@ static void update_variables(bool in_flight) spu_config.iUseInterpolation = 0; } -#if P_HAVE_PTHREAD +#ifdef USE_ASYNC_SPU var.value = NULL; var.key = "pcsx_rearmed_spu_thread"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) @@ -2618,7 +2618,7 @@ static void update_variables(bool in_flight) spu_config.iUseThread = 1; else spu_config.iUseThread = 0; - if (spu_config.iUseThread != spu_thread_old) + if (spu_config.iUseThread != spu_thread_old && SPU_configure) SPU_configure(); } #endif diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 8b02f7c1..eb0c3b5a 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -907,7 +907,7 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "enabled", }, -#if P_HAVE_PTHREAD +#ifdef USE_ASYNC_SPU { "pcsx_rearmed_spu_thread", "Threaded SPU", @@ -922,7 +922,7 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "disabled", }, -#endif // P_HAVE_PTHREAD +#endif { "pcsx_rearmed_show_input_settings", "Show Input Settings", diff --git a/jni/Android.mk b/jni/Android.mk index 6f2bfd17..3e016ca9 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -8,6 +8,7 @@ $(shell cd "$(LOCAL_PATH)" && (rm ../include/revision.h_)) USE_LIBRETRO_VFS ?= 0 USE_ASYNC_CDROM ?= 1 USE_ASYNC_GPU ?= 1 +USE_ASYNC_SPU ?= 1 USE_RTHREADS ?= 0 NDRC_THREAD ?= 1 @@ -244,6 +245,10 @@ SOURCES_C += $(GPU_DIR)/gpu_async.c COREFLAGS += -DUSE_ASYNC_GPU USE_RTHREADS := 1 endif +ifeq ($(USE_ASYNC_SPU),1) +COREFLAGS += -DUSE_ASYNC_SPU +USE_RTHREADS := 1 +endif ifeq ($(USE_RTHREADS),1) SOURCES_C += \ $(FRONTEND_DIR)/pcsxr-threads.c \ diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 17543716..05471de8 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -262,7 +262,7 @@ typedef struct sample_buf_rvb sb_rvb; // for reverb filtering int interpolation; -#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) +#if defined(USE_ASYNC_SPU) || defined(WANT_THREAD_CODE) sample_buf * sb_thread; sample_buf sb_thread_[MAXCHAN+1]; #endif diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index be43c2c8..046ec9a2 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -257,7 +257,7 @@ long DoFreeze(int ulFreezeMode, struct SPUFreeze * pF, unsigned short **ram, if (!pF || !pF2) return 0; // first check pFO = pF2; -#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) +#if defined(USE_ASYNC_SPU) || defined(WANT_THREAD_CODE) sb_rvb = (sample_buf_rvb *)&spu.sb_thread[MAXCHAN]; #endif if(ulFreezeMode) // info or save? diff --git a/plugins/dfsound/reverb.c b/plugins/dfsound/reverb.c index 99f84e63..a40fb585 100644 --- a/plugins/dfsound/reverb.c +++ b/plugins/dfsound/reverb.c @@ -115,7 +115,7 @@ static void MixREVERB(int *SSumLR, int *RVB, int ns_to, int curr_addr, int vIIR = rvb->vIIR; int ns; -#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) +#if defined(USE_ASYNC_SPU) || defined(WANT_THREAD_CODE) // this is reusing sb_thread[] due to complications with spu_c64x //sb = (sample_buf_rvb *)&spu.sb_thread[MAXCHAN]; #endif diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index b4ac7b6f..76f76afe 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -695,7 +695,7 @@ static void do_samples_finish(int *SSumLR, int ns_to, // optional worker thread handling -#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) +#if defined(USE_ASYNC_SPU) || defined(WANT_THREAD_CODE) // worker thread state static struct spu_worker { @@ -990,7 +990,7 @@ static void sync_worker_thread(int force_no_thread) {} static const void * const worker = NULL; -#endif // P_HAVE_PTHREAD || defined(WANT_THREAD_CODE) +#endif // defined(USE_ASYNC_SPU) || defined(WANT_THREAD_CODE) //////////////////////////////////////////////////////////////////////// // MAIN SPU FUNCTION @@ -1298,7 +1298,7 @@ static void RemoveStreams(void) /* special code for TI C64x DSP */ #include "spu_c64x.c" -#elif P_HAVE_PTHREAD +#elif defined(USE_ASYNC_SPU) #include "../../frontend/pcsxr-threads.h" #ifdef _3DS @@ -1356,6 +1356,9 @@ static void init_spu_thread(void) { int ret; + spu.sb_thread = spu.sb_thread_; + if (!spu_config.iUseThread) + return; if (worker) return; worker = calloc(1, sizeof(*worker)); @@ -1396,7 +1399,7 @@ static void exit_spu_thread(void) worker = NULL; } -#else // if !P_HAVE_PTHREAD +#else // if !defined(USE_ASYNC_SPU) static void init_spu_thread(void) { @@ -1438,11 +1441,7 @@ long CALLBACK SPUinit(void) if (spu_config.iVolume == 0) spu_config.iVolume = 768; // 1024 is 1.0 - spu.sb_thread = spu.sb_thread_; -#ifndef C64X_DSP - if (spu_config.iUseThread) -#endif - init_spu_thread(); + init_spu_thread(); for (i = 0; i < MAXCHAN; i++) // loop sound channels { @@ -1504,10 +1503,12 @@ long CALLBACK SPUshutdown(void) void CALLBACK SPUconfigure(void) { +#ifndef C64X_DSP if (spu.bSpuInit && spu_config.iUseThread) init_spu_thread(); else exit_spu_thread(); +#endif } // SETUP CALLBACKS diff --git a/plugins/spunull/spunull.c b/plugins/spunull/spunull.c index cd27205d..40c8fe33 100644 --- a/plugins/spunull/spunull.c +++ b/plugins/spunull/spunull.c @@ -443,91 +443,6 @@ long DoFreeze(int ulFreezeMode, SPUFreeze_t * pF, unsigned short **ram, return 1; } - -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// UNUSED WINDOWS FUNCS... YOU SHOULDN'T USE THEM IN LINUX - -long CALLBACK SPUconfigure(void) -{ - return 0; -} - -void CALLBACK SPUabout(void) -{ -} - -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -// OLD PSEMU 1 FUNCS... YOU SHOULDN'T USE THEM - -unsigned short CALLBACK SPUgetOne(unsigned long val) -{ - if(spuAddr!=0xffffffff) - { - return SPUreadDMA(); - } - if(val>=512*1024) val=512*1024-1; - return spuMem[val>>1]; -} - -void CALLBACK SPUputOne(unsigned long val,unsigned short data) -{ - if(spuAddr!=0xffffffff) - { - SPUwriteDMA(data); - return; - } - if(val>=512*1024) val=512*1024-1; - spuMem[val>>1] = data; -} - -void CALLBACK SPUplaySample(unsigned char ch) -{ -} - -void CALLBACK SPUsetAddr(unsigned char ch, unsigned short waddr) -{ - //s_chan[ch].pStart=spuMemC+((unsigned long) waddr<<3); -} - -void CALLBACK SPUsetPitch(unsigned char ch, unsigned short pitch) -{ - //SetPitch(ch,pitch); -} - -void CALLBACK SPUsetVolumeL(unsigned char ch, short vol) -{ - //SetVolumeL(ch,vol); -} - -void CALLBACK SPUsetVolumeR(unsigned char ch, short vol) -{ - //SetVolumeR(ch,vol); -} - -void CALLBACK SPUstartChannels1(unsigned short channels) -{ - //SoundOn(0,16,channels); -} - -void CALLBACK SPUstartChannels2(unsigned short channels) -{ - //SoundOn(16,24,channels); -} - -void CALLBACK SPUstopChannels1(unsigned short channels) -{ - //SoundOff(0,16,channels); -} - -void CALLBACK SPUstopChannels2(unsigned short channels) -{ - //SoundOff(16,24,channels); -} - void CALLBACK SPUregisterScheduleCb(void (CALLBACK *callback)(unsigned int)) { }