Another minor change to the Qt sound scaling algorithm to better scale at frame rates faster than realtime.

This commit is contained in:
mjbudd77 2021-08-08 14:02:06 -04:00
parent 07455a7201
commit 52b5ee51f4
1 changed files with 8 additions and 10 deletions

View File

@ -277,18 +277,14 @@ WriteSound(int32 *buf,
int udrFlowDup = 1; int udrFlowDup = 1;
static int skipCounter = 0; static int skipCounter = 0;
if ( g_fpsScale >= 0.90 ) if ( g_fpsScale >= 0.99995 )
{ {
uflowMode = 0; uflowMode = 0;
ovrFlowSkip = (int)(g_fpsScale); ovrFlowSkip = (int)(g_fpsScale * 1000);
if ( ovrFlowSkip < 1 )
{
ovrFlowSkip = 1;
}
if ( s_BufferIn >= s_BufferSize50 ) if ( s_BufferIn >= s_BufferSize50 )
{ {
ovrFlowSkip++; ovrFlowSkip += 1000;
} }
} }
else else
@ -345,7 +341,7 @@ WriteSound(int32 *buf,
} }
else else
{ {
if ( ovrFlowSkip == 1 ) if ( ovrFlowSkip <= 1000 )
{ // Perfect one to one realtime { // Perfect one to one realtime
skipCounter = 0; skipCounter = 0;
@ -388,7 +384,7 @@ WriteSound(int32 *buf,
} }
} }
if ( skipCounter == 0 ) if ( skipCounter >= ovrFlowSkip )
{ {
s_Buffer[s_BufferWrite] = *buf; s_Buffer[s_BufferWrite] = *buf;
s_BufferWrite = (s_BufferWrite + 1) % s_BufferSize; s_BufferWrite = (s_BufferWrite + 1) % s_BufferSize;
@ -396,8 +392,10 @@ WriteSound(int32 *buf,
SDL_LockAudio(); SDL_LockAudio();
s_BufferIn++; s_BufferIn++;
SDL_UnlockAudio(); SDL_UnlockAudio();
skipCounter -= ovrFlowSkip;
} }
skipCounter = (skipCounter+1) % ovrFlowSkip; skipCounter = (skipCounter+1000);
Count--; Count--;
buf++; buf++;