When scientific theories, technical gadgets, or software get very complicated, one needs to stop and deliberate. I just read a thrilling book about the “theory of everything”, Parallel Worlds by Michio Kaku. Dr. Kaku hopes that the “theory of everything” can be summarized in an equation no longer than an inch. Today’s “standard model” (of elementary particles) is a mess with hundreds of different particles and 19 arbitrary constants, only experimentally determinable. And there is no way gravity can be squeezed into the theory.
The different sync methods I have implemented have come to resemble the standard model I’m afraid. They work (on my development computer) but the code is getting complicated with a lot of special cases to handle. The complexity warning bells are ringing loudly.
I have therefore deliberated and tacked onto a different course, hoping for more tail-wind. Instead of letting the incoming samples determine when to display something, I now let the player display a frame at each vsync. For each vsync the renderer picks the frame in the buffer of incoming frames that is closest to the presentation time. This means that frames from a 25 fps movie are presented exactly twice when using a 50 Hz refresh rate. I hope that this algorithm solves some other issues as well and for instance gives the “Present at nearest vsync” option as a default.
Initial experiments are encouraging but I’ll run some more tests before I publish anything. And I’m still in the middle of that crunch at work so development pace is slow. Please check back later!