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