mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a fix for a potential wrap-around bug in BufferingAudioSource
This commit is contained in:
parent
61fd2a339d
commit
8154ccc4e5
1 changed files with 10 additions and 3 deletions
|
|
@ -168,9 +168,12 @@ bool BufferingAudioSource::waitForNextAudioBlockReady (const AudioSourceChannelI
|
|||
return true;
|
||||
|
||||
uint32 now = Time::getMillisecondCounter();
|
||||
const uint32 endTime = now + timeout;
|
||||
const uint32 startTime = now;
|
||||
|
||||
while (now <= endTime)
|
||||
uint32 elapsed = (now >= startTime ? now - startTime
|
||||
: (std::numeric_limits<uint32>::max() - startTime) + now);
|
||||
|
||||
while (elapsed <= timeout)
|
||||
{
|
||||
{
|
||||
const ScopedLock sl (bufferStartPosLock);
|
||||
|
|
@ -182,10 +185,14 @@ bool BufferingAudioSource::waitForNextAudioBlockReady (const AudioSourceChannelI
|
|||
return true;
|
||||
}
|
||||
|
||||
if (endTime > now && (! bufferReadyEvent.wait (static_cast<int> (endTime - now))))
|
||||
|
||||
|
||||
if (elapsed < timeout && (! bufferReadyEvent.wait (static_cast<int> (timeout - elapsed))))
|
||||
return false;
|
||||
|
||||
now = Time::getMillisecondCounter();
|
||||
elapsed = (now >= startTime ? now - startTime
|
||||
: (std::numeric_limits<uint32>::max() - startTime) + now);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue