From: notaz Date: Wed, 4 Jul 2012 15:25:11 +0000 (+0300) Subject: spu: remove all threading code X-Git-Tag: r15~39 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d75977b13fede33db381324c610561c6e723a8b;p=pcsx_rearmed.git spu: remove all threading code it is broken for a while now, and I have no intention to fix it. --- diff --git a/frontend/main.c b/frontend/main.c index 8df90365..e072cdec 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -38,7 +38,6 @@ extern int iUseReverb; extern int iUseInterpolation; extern int iXAPitch; extern int iSPUIRQWait; -extern int iUseTimer; extern int iVolume; int ready_to_go; @@ -159,7 +158,6 @@ void emu_set_default_config(void) iUseInterpolation = 1; iXAPitch = 0; iSPUIRQWait = 1; - iUseTimer = 2; iVolume = 768; #ifndef __ARM_ARCH_7A__ /* XXX */ iUseReverb = 0; diff --git a/frontend/menu.c b/frontend/menu.c index 7cdfe390..866c2b42 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -107,7 +107,6 @@ extern int iUseReverb; extern int iUseInterpolation; extern int iXAPitch; extern int iSPUIRQWait; -extern int iUseTimer; extern int iVolume; static const char *bioses[24]; @@ -309,7 +308,6 @@ static const struct { CE_INTVAL_V(iXAPitch, 3), CE_INTVAL_V(iUseInterpolation, 3), CE_INTVAL_V(iSPUIRQWait, 3), - CE_INTVAL_V(iUseTimer, 3), CE_INTVAL(warned_about_bios), CE_INTVAL(in_evdev_allow_abs_only), CE_INTVAL(volume_boost), @@ -1216,7 +1214,6 @@ static int menu_loop_plugin_gpu_peopsgl(int id, int keys) static const char *men_spu_interp[] = { "None", "Simple", "Gaussian", "Cubic", NULL }; static const char h_spu_volboost[] = "Large values cause distortion"; static const char h_spu_irq_wait[] = "Wait for CPU (recommended set to ON)"; -static const char h_spu_thread[] = "Run sound emulation in main thread (recommended)"; static menu_entry e_menu_plugin_spu[] = { @@ -1225,7 +1222,6 @@ static menu_entry e_menu_plugin_spu[] = mee_enum ("Interpolation", 0, iUseInterpolation, men_spu_interp), mee_onoff ("Adjust XA pitch", 0, iXAPitch, 1), mee_onoff_h ("SPU IRQ Wait", 0, iSPUIRQWait, 1, h_spu_irq_wait), - mee_onoff_h ("Sound in main thread", 0, iUseTimer, 2, h_spu_thread), mee_end, }; diff --git a/maemo/main.c b/maemo/main.c index 45317040..481e9cd4 100644 --- a/maemo/main.c +++ b/maemo/main.c @@ -19,9 +19,6 @@ #include "../plugins/dfinput/main.h" #include "maemo_common.h" -// sound plugin -extern int iUseTimer; - int g_opts = OPT_SHOWFPS; int g_maemo_opts; char file_name[MAXPATHLEN]; @@ -81,7 +78,6 @@ int maemo_main(int argc, char **argv) } else if (!strcmp(argv[i],"-fullscreen")) g_maemo_opts |= 2; else if (!strcmp(argv[i],"-accel")) g_maemo_opts |= 4; - else if (!strcmp(argv[i],"-sputhreaded")) iUseTimer=1; else if (!strcmp(argv[i],"-nosound")) strcpy(Config.Spu, "spunull.so"); else if (!strcmp(argv[i], "-bdir")) sprintf(Config.BiosDir, "%s", argv[++i]); else if (!strcmp(argv[i], "-bios")) sprintf(Config.Bios, "%s", argv[++i]); diff --git a/plugins/dfsound/cfg.c b/plugins/dfsound/cfg.c deleted file mode 100644 index 5801453e..00000000 --- a/plugins/dfsound/cfg.c +++ /dev/null @@ -1,161 +0,0 @@ -/*************************************************************************** - cfg.c - description - ------------------- - begin : Wed May 15 2002 - copyright : (C) 2002 by Pete Bernert - email : BlackDove@addcom.de - ***************************************************************************/ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. See also the license.txt file for * - * additional informations. * - * * - ***************************************************************************/ - -#include "stdafx.h" - -#define _IN_CFG - -#include "externals.h" - -//////////////////////////////////////////////////////////////////////// -// LINUX CONFIG/ABOUT HANDLING -//////////////////////////////////////////////////////////////////////// - -#include - -//////////////////////////////////////////////////////////////////////// -// START EXTERNAL CFG TOOL -//////////////////////////////////////////////////////////////////////// - -void StartCfgTool(char * pCmdLine) -{ - FILE * cf; - char filename[255]; - - strcpy(filename,"cfgDFSound"); - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - if(fork()==0) - { - execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL); - exit(0); - } - } - else - { - strcpy(filename,"cfg/cfgDFSound"); - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - if(fork()==0) - { - chdir("cfg"); - execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL); - exit(0); - } - } - else - { - sprintf(filename,"%s/cfgDFSound",getenv("HOME")); - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - if(fork()==0) - { - chdir(getenv("HOME")); - execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL); - exit(0); - } - } - else printf("Sound error: cfgDFSound not found!\n"); - } - } -} - -///////////////////////////////////////////////////////// -// READ LINUX CONFIG FILE -///////////////////////////////////////////////////////// - -static void ReadConfigFile(void) -{ - FILE *in;char t[256];int len; - char * pB, * p; - - strcpy(t,"dfsound.cfg"); - in = fopen(t,"rb"); - if(!in) - { - strcpy(t,"cfg/dfsound.cfg"); - in = fopen(t,"rb"); - if(!in) - { - sprintf(t,"%s/dfsound.cfg",getenv("HOME")); - in = fopen(t,"rb"); - if(!in) return; - } - } - - pB = (char *)malloc(32767); - memset(pB,0,32767); - - len = fread(pB, 1, 32767, in); - fclose(in); - - strcpy(t,"\nVolume");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} - if(p) iVolume=4-atoi(p+len); - if(iVolume<1) iVolume=1; - if(iVolume>4) iVolume=4; - - strcpy(t,"\nXAPitch");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} - if(p) iXAPitch=atoi(p+len); - if(iXAPitch<0) iXAPitch=0; - if(iXAPitch>1) iXAPitch=1; - - strcpy(t,"\nHighCompMode");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} - if(p) iUseTimer=atoi(p+len); - if(iUseTimer<0) iUseTimer=0; - // note: timer mode 1 (win time events) is not supported - // in linux. But timer mode 2 (spuupdate) is safe to use. - if(iUseTimer) iUseTimer=2; - - strcpy(t,"\nSPUIRQWait");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} - if(p) iSPUIRQWait=atoi(p+len); - if(iSPUIRQWait<0) iSPUIRQWait=0; - if(iSPUIRQWait>1) iSPUIRQWait=1; - - strcpy(t,"\nUseReverb");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} - if(p) iUseReverb=atoi(p+len); - if(iUseReverb<0) iUseReverb=0; - if(iUseReverb>2) iUseReverb=2; - - strcpy(t,"\nUseInterpolation");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} - if(p) iUseInterpolation=atoi(p+len); - if(iUseInterpolation<0) iUseInterpolation=0; - if(iUseInterpolation>3) iUseInterpolation=3; - - free(pB); -} - -///////////////////////////////////////////////////////// -// READ CONFIG called by spu funcs -///////////////////////////////////////////////////////// - -void ReadConfigSPU(void) -{ - iVolume=2; - iXAPitch=0; - iSPUIRQWait=0; - iUseTimer=2; - iUseReverb=2; - iUseInterpolation=2; - - ReadConfigFile(); -} diff --git a/plugins/dfsound/cfg.h b/plugins/dfsound/cfg.h deleted file mode 100644 index 14f3a8d6..00000000 --- a/plugins/dfsound/cfg.h +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - cfg.h - description - ------------------- - begin : Wed May 15 2002 - copyright : (C) 2002 by Pete Bernert - email : BlackDove@addcom.de - ***************************************************************************/ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. See also the license.txt file for * - * additional informations. * - * * - ***************************************************************************/ - -void ReadConfigSPU(void); -void StartCfgTool(char * pCmdLine); diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index c9f20ca8..18521ce4 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -203,7 +203,6 @@ extern unsigned char * pSpuBuffer; extern int iVolume; extern int iXAPitch; -extern int iUseTimer; extern int iSPUIRQWait; extern int iDebugMode; extern int iRecordMode; @@ -221,8 +220,6 @@ extern unsigned short spuCtrl; extern unsigned short spuStat; extern unsigned short spuIrq; extern unsigned long spuAddr; -extern int bEndThread; -extern int bThreadEnded; extern int bSpuInit; extern unsigned int dwNewChannel; extern unsigned int dwChannelOn; diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index 1c037fe1..d7e45b11 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -214,8 +214,6 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) if(ulFreezeMode==2) return 1; // info mode? ok, bye // save mode: - RemoveTimer(); // stop timer - memcpy(pF->cSPURam,spuMem,0x80000); // copy common infos memcpy(pF->cSPUPort,regArea,0x200); @@ -246,16 +244,12 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) pFO->s_chan[i].pLoop-=(unsigned long)spuMemC; } - SetupTimer(); // sound processing on again - return 1; //--------------------------------------------------// } if(ulFreezeMode!=0) return 0; // bad mode? bye - RemoveTimer(); // we stop processing while doing the save! - memcpy(spuMem,pF->cSPURam,0x80000); // get ram memcpy(regArea,pF->cSPUPort,0x200); @@ -286,7 +280,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) // fix to prevent new interpolations from crashing for(i=0;iTESTSIZE)) // and still enuff data in sound buffer? { - iSecureStart=0; // reset secure - - if(iUseTimer) return 0; // linux no-thread mode? bye - usleep(PAUSE_L); // else sleep for x ms (linux) - - if(dwNewChannel) iSecureStart=1; // if a new channel kicks in (or, of course, sound buffer runs low), we will leave the loop + return 0; } //--------------------------------------------------// continue from irq handling in timer mode? @@ -797,19 +777,7 @@ static void *MAINThread(void *arg) { iSpuAsyncWait=1; bIRQReturn=0; - if(iUseTimer!=2) - { - DWORD dwWatchTime=timeGetTime_spu()+2500; - - while(iSpuAsyncWait && !bEndThread && - timeGetTime_spu() no init, no call + if(!bSpuInit) return; // -> no init, no call - MAINThread(0); // -> linux high-compat mode + do_samples(); - // abuse iSpuAsyncWait mechanism to reduce calls to above function - // to make it do larger chunks - // note: doing it less often than once per frame causes skips - iSpuAsyncWait=1; - } + // abuse iSpuAsyncWait mechanism to reduce calls to above function + // to make it do larger chunks + // note: doing it less often than once per frame causes skips + iSpuAsyncWait=1; } // SPU UPDATE... new epsxe func @@ -961,37 +922,12 @@ int CALLBACK SPUplayCDDAchannel(short *pcm, int nbytes) return FeedCDDA((unsigned char *)pcm, nbytes); } -// SETUPTIMER: init of certain buffers and threads/timers -void SetupTimer(void) +// to be called after state load +void ClearWorkingState(void) { memset(SSumLR,0,sizeof(SSumLR)); // init some mixing buffers - memset(iFMod,0,NSSIZE*sizeof(int)); + memset(iFMod,0,sizeof(iFMod)); pS=(short *)pSpuBuffer; // setup soundbuffer pointer - - bEndThread=0; // init thread vars - bThreadEnded=0; - bSpuInit=1; // flag: we are inited - - if(!iUseTimer) // linux: use thread - { - pthread_create(&thread, NULL, MAINThread, NULL); - } -} - -// REMOVETIMER: kill threads/timers -void RemoveTimer(void) -{ - bEndThread=1; // raise flag to end thread - - if(!iUseTimer) // linux tread? - { - int i=0; - while(!bThreadEnded && i<2000) {usleep(1000L);i++;} // -> wait until thread has ended - if(thread!=(pthread_t)-1) {pthread_cancel(thread);thread=(pthread_t)-1;} // -> cancel thread anyway - } - - bThreadEnded=0; // no more spu is running - bSpuInit=0; } // SETUPSTREAMS: init most of the spu buffers @@ -1031,7 +967,11 @@ void SetupStreams(void) s_chan[i].pCurr=spuMemC; } - pMixIrq=spuMemC; // enable decoded buffer irqs by setting the address + pMixIrq=spuMemC; // enable decoded buffer irqs by setting the address + + ClearWorkingState(); + + bSpuInit=1; // flag: we are inited } // REMOVESTREAMS: free most buffer @@ -1058,8 +998,6 @@ long CALLBACK SPUinit(void) spuIrq = 0; spuAddr = 0xffffffff; - bEndThread = 0; - bThreadEnded = 0; spuMemC = (unsigned char *)spuMem; pMixIrq = 0; memset((void *)s_chan, 0, (MAXCHAN + 1) * sizeof(SPUCHAN)); @@ -1067,7 +1005,6 @@ long CALLBACK SPUinit(void) //iSPUIRQWait = 0; lastch = -1; - //ReadConfigSPU(); // read user stuff SetupStreams(); // prepare streaming return 0; @@ -1079,7 +1016,6 @@ long CALLBACK SPUopen(void) if (bSPUIsOpen) return 0; // security for some stupid main emus SetupSound(); // setup sound (before init!) - SetupTimer(); // timer for feeding data bSPUIsOpen = 1; @@ -1093,7 +1029,6 @@ long CALLBACK SPUclose(void) bSPUIsOpen = 0; // no more open - RemoveTimer(); // no more feeding RemoveSound(); // no more sound handling return 0; @@ -1104,6 +1039,7 @@ long CALLBACK SPUshutdown(void) { SPUclose(); RemoveStreams(); // no more streaming + bSpuInit=0; return 0; } diff --git a/plugins/dfsound/spu.h b/plugins/dfsound/spu.h index 048f6434..d42425d6 100644 --- a/plugins/dfsound/spu.h +++ b/plugins/dfsound/spu.h @@ -15,7 +15,6 @@ * * ***************************************************************************/ -void SetupTimer(void); -void RemoveTimer(void); +void ClearWorkingState(void); void CALLBACK SPUplayADPCMchannel(xa_decode_t *xap); int CALLBACK SPUplayCDDAchannel(short *pcm, int bytes);