Reduce source:tell drift after a streaming Source loops.

Fixes #1810
This commit is contained in:
Sasha Szpakowski
2022-12-04 19:36:38 -04:00
parent e5495d6436
commit a51d45b1a3
+13 -8
View File
@@ -1160,6 +1160,19 @@ int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
decoded = 0;
}
// This shouldn't run after toLoop is calculated in this streamAtomic call,
// otherwise it'll decrease too quickly.
// TODO: this code is hard to understand, can it be made more clear?
// It's meant to reset offsetSamples once OpenAL starts processing the first
// queued buffer after a loop.
if (toLoop > 0)
{
if (--toLoop == 0)
{
offsetSamples = 0;
}
}
if (decoder->isFinished() && isLooping())
{
int queued, processed;
@@ -1172,14 +1185,6 @@ int Source::streamAtomic(ALuint buffer, love::sound::Decoder *d)
d->rewind();
}
if (toLoop > 0)
{
if (--toLoop == 0)
{
offsetSamples = 0;
}
}
return decoded;
}