Make sound processing use less CPU cycles.

This commit is contained in:
n-a-c-h
2005-11-26 17:24:40 +00:00
parent b80ce23ef6
commit cd578b0e73

View File

@@ -1048,11 +1048,8 @@ void sem_sleep_die(void)
void UpdateVFrame(void)
{
const int SPCSize = 256;
int i;
//Quick fix for GUI CPU usage
if (GUIOn || GUIOn2 || EMUPause) usleep(6000);
if (GUIOn || GUIOn2 || EMUPause) { usleep(6000); }
CheckTimers();
Main_Proc();
@@ -1061,31 +1058,31 @@ void UpdateVFrame(void)
/* take care of the things we left behind last time */
SDL_LockAudio();
while (Buffer_fill < Buffer_len) {
while (Buffer_fill < Buffer_len)
{
short *ptr = (short*)&Buffer[Buffer_tail];
SoundProcess();
for (i = 0; i < SPCSize; i++, ptr++)
{
if (T36HZEnabled)
{
*ptr = 0;
memset(ptr, 0, 256*sizeof(short));
}
else
{
if (DSPBuffer[i] > 32767)
*ptr = 32767;
else if (DSPBuffer[i] < -32767)
*ptr = -32767;
else
*ptr = DSPBuffer[i];
int *d = DSPBuffer;
int *end_d = DSPBuffer+256;
for (; d < end_d; d++, ptr++)
{
if (*d > 32767) { *ptr = 32767; }
else if (*d < -32767) { *ptr = -32767; }
else { *ptr = *d; }
}
}
Buffer_fill += SPCSize * 2;
Buffer_tail += SPCSize * 2;
if (Buffer_tail >= Buffer_len) Buffer_tail = 0;
Buffer_fill += 512;
Buffer_tail += 512;
if (Buffer_tail >= Buffer_len) { Buffer_tail = 0; }
}
SDL_UnlockAudio();
}