skip frames when playing back IVF to prevent desyncs

This commit is contained in:
Ricardo Luís Vaz Silva 2024-03-31 19:00:06 -03:00 committed by Rachael Alexanderson
parent 5b2673f469
commit 64ffe9b97b

View file

@ -554,21 +554,34 @@ public:
bool stop = false;
if (clock >= nextframetime)
{
nextframetime += nsecsperframe;
auto img = GetFrameData();
if (!img || !FormatSupported(img->fmt))
{
Printf(PRINT_BOLD, "Failed reading next frame\n");
stop = true;
}
else
{
animtex.SetFrame(nullptr, img);
while(clock >= nextframetime)
{ // frameskipping
auto img = GetFrameData();
framenum++;
nextframetime += nsecsperframe;
if (framenum >= numframes || !img) break;
}
framenum++;
if (framenum < numframes)
{
auto img = GetFrameData();
if (!img || !FormatSupported(img->fmt))
{
Printf(PRINT_BOLD, "Failed reading next frame\n");
stop = true;
}
else
{
animtex.SetFrame(nullptr, img);
}
framenum++;
}
if (framenum >= numframes) stop = true;
bool nostopsound = (flags & NOSOUNDCUTOFF);