Tested on Linux and Windows with a file containing some very large frames. Without the patch, the audio would stutter or crackle as the frames were encountered. This approach seems to successfully remove issue.
There is still one small regression: when changing the playback speed or fps right during playback using mouse wheel there is a weird hiccup in the playback. Basically, it stops playing for a couple of seconds. Without the patch it works smoothly, just changes the speed of the clip smoothly :(
There is still the same bug in the patch. I found at least one reason for that: you changed the meaning of 'normalizedPlaybackTime'. Previously it was normalized by the "expected frame update period" and now your implementation normalizes it by the total animation time. And the problem is that your new implementation doesn't take "playback speed" into account (previously, the speed was already taken int account in the update period). Therefore every change of the playback speed drives the code crazy.
So the current regressions:
- When changing playback speed slider while playback, the cursor jumps like crazy. Most of the time it tries to jump over the end of the selection and is returned to the beginning by the wrapping algorithm.
- When changing FPS slider, the playback stops for some time. If you change the slider to 1 or 2 FPS, then the playback basically stops completely.
- There is also a weird thing. If I add an audio channel to the image, GStreamer fails (with some internal assert in the console) and the playback becomes really slow. Without the patch, GStreamer also fails, but the playback is not delayed in any way. I think it might also be considered as a regression :(
Changed to using frames as the fundamental unit instead of two different types of milliseconds. The logic is now hopefully clearer and more correct.
Adjusting FPS and playback speed seem to work as expected now.
Looks correct. There is still one small regression: the frame selection is reset after stopping the playback if one changed speed or FPS durng the playback at least once. But this problem can be fixed later on.
Check if we really need a precise timer, they are expensive