aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authornotaz2011-02-08 01:27:36 +0200
committernotaz2011-02-10 02:07:54 +0200
commit8680e8229414b74335e2c1d05cc678cf8bab685b (patch)
tree58c49ccb5125df42bf9549d34d971889aa81972d /plugins
parent8f8926485e641efb187ff9ae11cef9d23d1e8982 (diff)
downloadpcsx_rearmed-8680e8229414b74335e2c1d05cc678cf8bab685b.tar.gz
pcsx_rearmed-8680e8229414b74335e2c1d05cc678cf8bab685b.tar.bz2
pcsx_rearmed-8680e8229414b74335e2c1d05cc678cf8bab685b.zip
spu: handle channels better in 'IRQ wait' case
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dfsound/spu.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c
index 8936e45..084fccf 100644
--- a/plugins/dfsound/spu.c
+++ b/plugins/dfsound/spu.c
@@ -441,7 +441,7 @@ INLINE int iGetInterpolationVal(int ch)
static void *MAINThread(void *arg)
{
- int s_1,s_2,fa,ns;
+ int s_1,s_2,fa,ns,ns_from,ns_to;
#if !defined(_MACOSX) && !defined(__arm__)
int voldiv = iVolume;
#else
@@ -480,17 +480,19 @@ static void *MAINThread(void *arg)
//--------------------------------------------------// continue from irq handling in timer mode?
+ ns_from=0;
+ ns_to=NSSIZE;
+ ch=0;
if(lastch>=0) // will be -1 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
+ ch=lastch; ns_from=lastns+1; lastch=-1; // -> setup all kind of vars to continue
}
//--------------------------------------------------//
//- main channel loop -//
//--------------------------------------------------//
{
- for(ch=0;ch<MAXCHAN;ch++) // loop em all... we will collect 1 ms of sound of each playing channel
+ for(;ch<MAXCHAN;ch++) // loop em all... we will collect 1 ms of sound of each playing channel
{
if(s_chan[ch].bNew) StartSound(ch); // start new sound
if(!s_chan[ch].bOn) continue; // channel not playing? next
@@ -498,8 +500,7 @@ static void *MAINThread(void *arg)
if(s_chan[ch].iActFreq!=s_chan[ch].iUsedFreq) // new psx frequency?
VoiceChangeFrequency(ch);
- ns=0;
- while(ns<NSSIZE) // loop until 1 ms of data is reached
+ for(ns=ns_from;ns<ns_to;ns++) // loop until 1 ms of data is reached
{
if(s_chan[ch].bFMod==1 && iFMod[ns]) // fmod freq channel
FModChangeFrequency(ch,ns);
@@ -570,6 +571,9 @@ static void *MAINThread(void *arg)
{
iSpuAsyncWait=1;
bIRQReturn=1;
+ lastch=ch;
+ lastns=ns;
+ ns_to=ns+1;
}
}
}
@@ -597,26 +601,6 @@ static void *MAINThread(void *arg)
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)
- usleep(1000L);
- }
- else
- {
- lastch=ch;
- lastns=ns;
-
- return 0;
- }
- }
-
GOON: ;
}
@@ -657,14 +641,31 @@ GOON: ;
////////////////////////////////////////////////
// ok, go on until 1 ms data of this channel is collected
- ns++;
s_chan[ch].spos += s_chan[ch].sinc;
-
}
ENDX: ;
}
}
+ 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)
+ usleep(1000L);
+ continue;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+
//---------------------------------------------------//
//- here we have another 1 ms of sound data
//---------------------------------------------------//