aboutsummaryrefslogtreecommitdiff
path: root/plugins/dfsound
diff options
context:
space:
mode:
authornotaz2011-03-01 00:48:20 +0200
committernotaz2011-03-01 17:35:19 +0200
commit97ea407715c0eafc8d73ffc5477f6d7e6ad8f20b (patch)
tree039162811486c4061487e01de966597ab055c056 /plugins/dfsound
parent9cf0ddbcdf4a2d72348df35695d09b36d23a2d0a (diff)
downloadpcsx_rearmed-97ea407715c0eafc8d73ffc5477f6d7e6ad8f20b.tar.gz
pcsx_rearmed-97ea407715c0eafc8d73ffc5477f6d7e6ad8f20b.tar.bz2
pcsx_rearmed-97ea407715c0eafc8d73ffc5477f6d7e6ad8f20b.zip
spu: drop unused mono code
also merge the mix buffers - the idea was to make use of neon there but I've decided againt it, it wouldn't improve things much according to profiling.
Diffstat (limited to 'plugins/dfsound')
-rw-r--r--plugins/dfsound/alsa.c6
-rw-r--r--plugins/dfsound/cfg.c6
-rw-r--r--plugins/dfsound/externals.h1
-rw-r--r--plugins/dfsound/oss.c11
-rw-r--r--plugins/dfsound/pulseaudio.c5
-rw-r--r--plugins/dfsound/sdl.c3
-rw-r--r--plugins/dfsound/spu.c41
-rw-r--r--plugins/dfsound/xa.c30
8 files changed, 33 insertions, 70 deletions
diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c
index 2eba878..7e59433 100644
--- a/plugins/dfsound/alsa.c
+++ b/plugins/dfsound/alsa.c
@@ -40,8 +40,7 @@ void SetupSound(void)
unsigned int period_time = buffer_time / 4;
int err;
- if (iDisStereo) pchannels = 1;
- else pchannels=2;
+ pchannels=2;
pspeed = 44100;
format = SND_PCM_FORMAT_S16;
@@ -153,6 +152,5 @@ void SoundFeedStreamData(unsigned char* pSound,long lBytes)
if (snd_pcm_state(handle) == SND_PCM_STATE_XRUN)
snd_pcm_prepare(handle);
- snd_pcm_writei(handle,pSound,
- iDisStereo ? lBytes / 2 : lBytes / 4);
+ snd_pcm_writei(handle,pSound, lBytes / 4);
}
diff --git a/plugins/dfsound/cfg.c b/plugins/dfsound/cfg.c
index 7d087bb..5801453 100644
--- a/plugins/dfsound/cfg.c
+++ b/plugins/dfsound/cfg.c
@@ -141,11 +141,6 @@ static void ReadConfigFile(void)
if(iUseInterpolation<0) iUseInterpolation=0;
if(iUseInterpolation>3) iUseInterpolation=3;
- strcpy(t,"\nDisStereo");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}
- if(p) iDisStereo=atoi(p+len);
- if(iDisStereo<0) iDisStereo=0;
- if(iDisStereo>1) iDisStereo=1;
-
free(pB);
}
@@ -161,7 +156,6 @@ void ReadConfigSPU(void)
iUseTimer=2;
iUseReverb=2;
iUseInterpolation=2;
- iDisStereo=0;
ReadConfigFile();
}
diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h
index 92683a9..90e26ce 100644
--- a/plugins/dfsound/externals.h
+++ b/plugins/dfsound/externals.h
@@ -205,7 +205,6 @@ extern int iDebugMode;
extern int iRecordMode;
extern int iUseReverb;
extern int iUseInterpolation;
-extern int iDisStereo;
// MISC
extern int iSpuAsyncWait;
diff --git a/plugins/dfsound/oss.c b/plugins/dfsound/oss.c
index 929d921..b2685fb 100644
--- a/plugins/dfsound/oss.c
+++ b/plugins/dfsound/oss.c
@@ -46,9 +46,7 @@ void SetupSound(void)
int myfrag;
int oss_speed, oss_stereo;
- if(iDisStereo) pstereo=OSS_MODE_MONO;
- else pstereo=OSS_MODE_STEREO;
-
+ pstereo = OSS_MODE_STEREO;
oss_speed = pspeed;
oss_stereo = pstereo;
@@ -90,17 +88,12 @@ void SetupSound(void)
return;
}
- if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1)
+ if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1 || !oss_stereo)
{
printf("Stereo mode not supported!\n");
return;
}
- if(oss_stereo!=1)
- {
- iDisStereo=1;
- }
-
if(ioctl(oss_audio_fd,SNDCTL_DSP_SPEED,&oss_speed)==-1)
{
printf("Sound frequency not supported\n");
diff --git a/plugins/dfsound/pulseaudio.c b/plugins/dfsound/pulseaudio.c
index 6005155..e5ffb59 100644
--- a/plugins/dfsound/pulseaudio.c
+++ b/plugins/dfsound/pulseaudio.c
@@ -195,10 +195,7 @@ void SetupSound (void)
// Set sample spec ////////////////////////////////////////////////////////
device.spec.format = PA_SAMPLE_S16NE;
- if (iDisStereo)
- device.spec.channels = 1;
- else
- device.spec.channels = 2;
+ device.spec.channels = 2;
device.spec.rate = settings.frequency;
pa_buffer_attr buffer_attributes;
diff --git a/plugins/dfsound/sdl.c b/plugins/dfsound/sdl.c
index 45ccba2..f677744 100644
--- a/plugins/dfsound/sdl.c
+++ b/plugins/dfsound/sdl.c
@@ -70,7 +70,7 @@ void SetupSound(void) {
spec.freq = 44100;
spec.format = AUDIO_S16SYS;
- spec.channels = iDisStereo ? 1 : 2;
+ spec.channels = 2;
spec.samples = 512;
spec.callback = SOUND_FillAudio;
@@ -80,7 +80,6 @@ void SetupSound(void) {
}
iBufSize = BUFFER_SIZE;
- if (iDisStereo) iBufSize /= 2;
pSndBuffer = (short *)malloc(iBufSize * sizeof(short));
if (pSndBuffer == NULL) {
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c
index ca0b97b..dc0f584 100644
--- a/plugins/dfsound/spu.c
+++ b/plugins/dfsound/spu.c
@@ -73,7 +73,6 @@ int iDebugMode=0;
int iRecordMode=0;
int iUseReverb=2;
int iUseInterpolation=2;
-int iDisStereo=0;
// MAIN infos struct for each channel
@@ -107,8 +106,7 @@ static const int f[8][2] = { { 0, 0 },
{ 115, -52 },
{ 98, -55 },
{ 122, -60 } };
-int SSumR[NSSIZE];
-int SSumL[NSSIZE];
+int SSumLR[NSSIZE*2];
int iFMod[NSSIZE];
int iCycle = 0;
short * pS;
@@ -623,8 +621,8 @@ static void *MAINThread(void *arg)
//////////////////////////////////////////////
// ok, left/right sound volume (psx volume goes from 0 ... 0x3fff)
- SSumL[ns]+=(sval*s_chan[ch].iLeftVolume)/0x4000L;
- SSumR[ns]+=(sval*s_chan[ch].iRightVolume)/0x4000L;
+ SSumLR[ns*2] +=(sval*s_chan[ch].iLeftVolume)/0x4000L;
+ SSumLR[ns*2+1]+=(sval*s_chan[ch].iRightVolume)/0x4000L;
//////////////////////////////////////////////
// now let us store sound data for reverb
@@ -670,37 +668,21 @@ ENDX: ;
///////////////////////////////////////////////////////
// mix all channels (including reverb) into one buffer
- if(iDisStereo) // no stereo?
+ for (ns = 0; ns < NSSIZE*2; )
{
- int dl, dr;
- for (ns = 0; ns < NSSIZE; ns++)
- {
- SSumL[ns] += MixREVERBLeft(ns);
-
- dl = SSumL[ns] / voldiv; SSumL[ns] = 0;
- if (dl < -32767) dl = -32767; if (dl > 32767) dl = 32767;
-
- SSumR[ns] += MixREVERBRight();
-
- dr = SSumR[ns] / voldiv; SSumR[ns] = 0;
- if (dr < -32767) dr = -32767; if (dr > 32767) dr = 32767;
- *pS++ = (dl + dr) / 2;
- }
- }
- else // stereo:
- for (ns = 0; ns < NSSIZE; ns++)
- {
- SSumL[ns] += MixREVERBLeft(ns);
+ SSumLR[ns] += MixREVERBLeft(ns/2);
- d = SSumL[ns] / voldiv; SSumL[ns] = 0;
+ d = SSumLR[ns] / voldiv; SSumLR[ns] = 0;
if (d < -32767) d = -32767; if (d > 32767) d = 32767;
*pS++ = d;
+ ns++;
- SSumR[ns] += MixREVERBRight();
+ SSumLR[ns] += MixREVERBRight();
- d = SSumR[ns] / voldiv; SSumR[ns] = 0;
+ d = SSumLR[ns] / voldiv; SSumLR[ns] = 0;
if(d < -32767) d = -32767; if(d > 32767) d = 32767;
*pS++ = d;
+ ns++;
}
//////////////////////////////////////////////////////
@@ -818,8 +800,7 @@ void CALLBACK SPUplayCDDAchannel(short *pcm, int nbytes)
// SETUPTIMER: init of certain buffers and threads/timers
void SetupTimer(void)
{
- memset(SSumR,0,NSSIZE*sizeof(int)); // init some mixing buffers
- memset(SSumL,0,NSSIZE*sizeof(int));
+ memset(SSumLR,0,sizeof(SSumLR)); // init some mixing buffers
memset(iFMod,0,NSSIZE*sizeof(int));
pS=(short *)pSpuBuffer; // setup soundbuffer pointer
diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c
index df60346..bdea89a 100644
--- a/plugins/dfsound/xa.c
+++ b/plugins/dfsound/xa.c
@@ -22,6 +22,8 @@
// will be included from spu.c
#ifdef _IN_SPU
+#define XA_HACK
+
////////////////////////////////////////////////////////////////////////
// XA GLOBALS
////////////////////////////////////////////////////////////////////////
@@ -61,40 +63,40 @@ INLINE void MixXA(void)
int ns;
uint32_t l;
- for(ns=0;ns<NSSIZE && XAPlay!=XAFeed;ns++)
+ for(ns=0;ns<NSSIZE*2 && XAPlay!=XAFeed;)
{
XALastVal=*XAPlay++;
if(XAPlay==XAEnd) XAPlay=XAStart;
#ifdef XA_HACK
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
#else
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
#endif
}
if(XAPlay==XAFeed && XARepeat)
{
XARepeat--;
- for(;ns<NSSIZE;ns++)
+ for(;ns<NSSIZE*2;)
{
#ifdef XA_HACK
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32768;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32768;
#else
- SSumL[ns]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
- SSumR[ns]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
+ SSumLR[ns++]+=(((short)(XALastVal&0xffff)) * iLeftXAVol)/32767;
+ SSumLR[ns++]+=(((short)((XALastVal>>16)&0xffff)) * iRightXAVol)/32767;
#endif
}
}
- for(ns=0;ns<NSSIZE && CDDAPlay!=CDDAFeed && (CDDAPlay!=CDDAEnd-1||CDDAFeed!=CDDAStart);ns++)
+ for(ns=0;ns<NSSIZE*2 && CDDAPlay!=CDDAFeed && (CDDAPlay!=CDDAEnd-1||CDDAFeed!=CDDAStart);)
{
l=*CDDAPlay++;
if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart;
- SSumL[ns]+=(((short)(l&0xffff)) * iLeftXAVol)/32767;
- SSumR[ns]+=(((short)((l>>16)&0xffff)) * iRightXAVol)/32767;
+ SSumLR[ns++]+=(((short)(l&0xffff)) * iLeftXAVol)/32767;
+ SSumLR[ns++]+=(((short)((l>>16)&0xffff)) * iRightXAVol)/32767;
}
}
@@ -122,7 +124,7 @@ INLINE void FeedXA(xa_decode_t *xap)
xapGlobal = xap; // store info for save states
XARepeat = 100; // set up repeat
-#ifdef XA_HACK
+#if 0//def XA_HACK
iSize=((45500*xap->nsamples)/xap->freq); // get size
#else
iSize=((44100*xap->nsamples)/xap->freq); // get size