spu: drop unused mono code
authornotaz <notasas@gmail.com>
Mon, 28 Feb 2011 22:48:20 +0000 (00:48 +0200)
committernotaz <notasas@gmail.com>
Tue, 1 Mar 2011 15:35:19 +0000 (17:35 +0200)
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.

plugins/dfsound/alsa.c
plugins/dfsound/cfg.c
plugins/dfsound/externals.h
plugins/dfsound/oss.c
plugins/dfsound/pulseaudio.c
plugins/dfsound/sdl.c
plugins/dfsound/spu.c
plugins/dfsound/xa.c

index 2eba878..7e59433 100644 (file)
@@ -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);
 }
index 7d087bb..5801453 100644 (file)
@@ -141,11 +141,6 @@ static void ReadConfigFile(void)
  if(iUseInterpolation<0) iUseInterpolation=0; \r
  if(iUseInterpolation>3) iUseInterpolation=3; \r
 \r
- strcpy(t,"\nDisStereo");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;} \r
- if(p)  iDisStereo=atoi(p+len); \r
- if(iDisStereo<0) iDisStereo=0; \r
- if(iDisStereo>1) iDisStereo=1; \r
-\r
  free(pB);\r
 }\r
 \r
@@ -161,7 +156,6 @@ void ReadConfigSPU(void)
  iUseTimer=2;\r
  iUseReverb=2;\r
  iUseInterpolation=2;\r
- iDisStereo=0;\r
 \r
  ReadConfigFile();\r
 }\r
index 92683a9..90e26ce 100644 (file)
@@ -205,7 +205,6 @@ extern int        iDebugMode;
 extern int        iRecordMode;\r
 extern int        iUseReverb;\r
 extern int        iUseInterpolation;\r
-extern int        iDisStereo;\r
 // MISC\r
 \r
 extern int iSpuAsyncWait;\r
index 929d921..b2685fb 100644 (file)
@@ -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");
index 6005155..e5ffb59 100644 (file)
@@ -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;
index 45ccba2..f677744 100644 (file)
@@ -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) {
index ca0b97b..dc0f584 100644 (file)
@@ -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
 
index df60346..bdea89a 100644 (file)
@@ -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