mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 932621 - Make sure the latency does not grow up in ScriptProcessorNode. r=ehsan
This commit is contained in:
parent
c0ac5df382
commit
3236595731
@ -111,15 +111,24 @@ public:
|
||||
// interval will be very short. |latency - bufferDuration| will be
|
||||
// negative, effectively moving back mLatency to a smaller and smaller
|
||||
// value, until it crosses zero, at which point we stop dropping buffers
|
||||
// and resume normal operation.
|
||||
// and resume normal operation. This does not work if at the same time,
|
||||
// the MSG thread was also slowed down, so if the latency on the MSG
|
||||
// thread is normal, and we are still dropping buffers, and mLatency is
|
||||
// still more than twice the duration of a buffer, we reset it and stop
|
||||
// dropping buffers.
|
||||
float latency = (now - mLastEventTime).ToSeconds();
|
||||
float bufferDuration = aBufferSize / mSampleRate;
|
||||
mLatency += latency - bufferDuration;
|
||||
mLastEventTime = now;
|
||||
if (mLatency > MAX_LATENCY_S || (mDroppingBuffers && mLatency > 0.0)) {
|
||||
if (mLatency > MAX_LATENCY_S ||
|
||||
(mDroppingBuffers && mLatency > 0.0 &&
|
||||
abs(latency - bufferDuration) < bufferDuration)) {
|
||||
mDroppingBuffers = true;
|
||||
return;
|
||||
} else {
|
||||
if (mDroppingBuffers) {
|
||||
mLatency = 0;
|
||||
}
|
||||
mDroppingBuffers = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user