aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-01-27 01:46:44 -0800
committerChris Robinson <[email protected]>2017-01-27 01:46:44 -0800
commit19e96c6fefa3a6e946c5f82ee8311917caeb6545 (patch)
tree250b8a4af68c1acc71e635e95e842cdd5b30c75a
parent67ffdf7a78ae3e48b1fbdd866ad7c2add7e5b6fd (diff)
Round and clamp the scaled update count with opensl
-rw-r--r--Alc/backends/opensl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Alc/backends/opensl.c b/Alc/backends/opensl.c
index 32f6fa7d..84e73f7b 100644
--- a/Alc/backends/opensl.c
+++ b/Alc/backends/opensl.c
@@ -282,13 +282,16 @@ static ALCboolean opensl_reset_playback(ALCdevice *Device)
//int sampleRate = Integer.parseInt(srateStr);
sampleRate = JCALL(env,CallStaticIntMethod)(int_cls, int_parseint, srateStr);
+ TRACE("Got system sample rate %uhz\n", sampleRate);
if(!sampleRate) sampleRate = Device->Frequency;
else sampleRate = maxu(sampleRate, MIN_OUTPUT_RATE);
}
if(sampleRate != Device->Frequency)
{
- Device->NumUpdates = Device->NumUpdates * sampleRate / Device->Frequency;
+ Device->NumUpdates = (Device->NumUpdates*sampleRate + (Device->Frequency>>1)) /
+ Device->Frequency;
+ Device->NumUpdates = maxu(Device->NumUpdates, 2);
Device->Frequency = sampleRate;
}
Device->FmtChans = DevFmtStereo;