summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSND\notaz_cp <SND\notaz_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-01-09 01:51:10 +0000
committerSND\notaz_cp <SND\notaz_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-01-09 01:51:10 +0000
commitf5df9147d46216814d91b0b902307329833ae5c2 (patch)
treeb2cbf9b078cd8294b679549817174223125ee9f9 /plugins
parent9af085242bda9ad4da78ef23e9d4ed180aa2c629 (diff)
downloadpcsxr-f5df9147d46216814d91b0b902307329833ae5c2.tar.gz
spu: do bIRQReturn on sample boundaries
fixes crackling on one of the channels (Chrono Cross) git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@82137 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/dfsound/freeze.c4
-rwxr-xr-xplugins/dfsound/spu.c70
2 files changed, 35 insertions, 39 deletions
diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c
index 82d700af..268e03ef 100755
--- a/plugins/dfsound/freeze.c
+++ b/plugins/dfsound/freeze.c
@@ -56,7 +56,7 @@ typedef struct
void LoadStateV5(SPUFreeze_t * pF); // newest version
void LoadStateUnknown(SPUFreeze_t * pF); // unknown format
-extern int lastch;
+extern int lastns;
////////////////////////////////////////////////////////////////////////
// SPUFREEZE: called by main emu on savestate load/save
@@ -141,7 +141,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF)
LoadStateV5(pF);
else LoadStateUnknown(pF);
- lastch = -1;
+ lastns = 0;
// repair some globals
for(i=0;i<=62;i+=2)
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c
index a0130224..c19be6e9 100755
--- a/plugins/dfsound/spu.c
+++ b/plugins/dfsound/spu.c
@@ -155,8 +155,7 @@ int iFMod[NSSIZE];
int iCycle = 0;
short * pS;
-int lastch=-1; // last channel processed on spu irq in timer mode
-static int lastns=0; // last ns pos
+int lastns=0; // last ns pos
static int iSecureStart=0; // secure start counter
////////////////////////////////////////////////////////////////////////
@@ -603,19 +602,20 @@ static void *MAINThread(void *arg)
if(dwNewChannel) iSecureStart=1; // if a new channel kicks in (or, of course, sound buffer runs low), we will leave the loop
}
+ ns=0;
+
//--------------------------------------------------// continue from irq handling in timer mode?
- if(lastch>=0) // will be -1 if no continue is pending
+ if(lastns>0) // will be 0 if no continue is pending
{
- ch=lastch; ns=lastns; lastch=-1; // -> setup all kind of vars to continue
- goto GOON; // -> directly jump to the continue point
+ ns=lastns; // -> setup all kind of vars to continue
+ lastns=0;
}
//--------------------------------------------------//
//- main channel loop -//
//--------------------------------------------------//
{
- ns=0;
decoded_voice = decoded_ptr;
while(ns<NSSIZE) // loop until 1 ms of data is reached
@@ -818,36 +818,6 @@ static void *MAINThread(void *arg)
s_chan[ch].pCurr=start; // store values for next cycle
s_chan[ch].s_1=s_1;
s_chan[ch].s_2=s_2;
-
- if(bIRQReturn) // special return for "spu irq - wait for cpu action"
- {
- bIRQReturn=0;
- if(iUseTimer!=2)
- {
- DWORD dwWatchTime=timeGetTime_spu()+2500;
-
- while(iSpuAsyncWait && !bEndThread &&
- timeGetTime_spu()<dwWatchTime)
-#ifdef _WINDOWS
- Sleep(1);
-#else
- usleep(1000L);
-#endif
- }
- else
- {
- lastch=ch;
- lastns=ns;
-
-#ifdef _WINDOWS
- return;
-#else
- return 0;
-#endif
- }
- }
-
-GOON: ;
}
fa=s_chan[ch].SB[s_chan[ch].iSBPos++]; // get sample data
@@ -938,6 +908,32 @@ GOON: ;
decoded_voice = old_ptr;
}
+ if(bIRQReturn) // special return for "spu irq - wait for cpu action"
+ {
+ bIRQReturn=0;
+ if(iUseTimer!=2)
+ {
+ DWORD dwWatchTime=timeGetTime_spu()+2500;
+
+ while(iSpuAsyncWait && !bEndThread &&
+ timeGetTime_spu()<dwWatchTime)
+#ifdef _WINDOWS
+ Sleep(1);
+#else
+ usleep(1000L);
+#endif
+ }
+ else
+ {
+ lastns=ns+1;
+
+#ifdef _WINDOWS
+ return;
+#else
+ return 0;
+#endif
+ }
+ }
ns++;
} // end ns
@@ -1341,7 +1337,7 @@ long CALLBACK SPUinit(void)
memset((void *)s_chan, 0, (MAXCHAN + 1) * sizeof(SPUCHAN));
pSpuIrq = 0;
iSPUIRQWait = 1;
- lastch = -1;
+ lastns = 0;
ReadConfig(); // read user stuff
SetupStreams(); // prepare streaming