Playing a "Stream" sound on the timeline triggers frame-skipping behavior in the Flash Player to keep the animation in sync with the sound. Ruffle does not fully implement this.
Currently, Ruffle does frame-skipping at all times, which more-or-less keeps audio in sync for most cases. However, if the audio still manages to get out of sync (because the player or the audio stalls for some amount of time), there is no mechanism to re-sync the animation. This also occurs immediately in some exotic situations, such as when a stream sound is played in a loaded movie that has a different framerate from the root movie.
This should hopefully handle all of these cases:
I'm thinking something like this:
- On the audio backend, stream sounds keep track of the frame they are on in the movieclip's timeline.
- Each frame while a stream sound is playing, the player can compare the movieclip's frame to the audio's frame. If these are different, adjust the player's frame timer to skip frames/stall the movie appropriately.
- Some investigation is necessary to figure out the Flash Player's behavior:
- How does Flash behave when multiple stream sounds are playing? Does it choose one sound to sync with? (Particularly test when the sounds are from movies with different framerates.)
- If there is a large discrepancy, say, the audio is suddenly a second+ ahead of the animation, how should we behave? Stop and restart the stream?
Playing a "Stream" sound on the timeline triggers frame-skipping behavior in the Flash Player to keep the animation in sync with the sound. Ruffle does not fully implement this.
Currently, Ruffle does frame-skipping at all times, which more-or-less keeps audio in sync for most cases. However, if the audio still manages to get out of sync (because the player or the audio stalls for some amount of time), there is no mechanism to re-sync the animation. This also occurs immediately in some exotic situations, such as when a stream sound is played in a loaded movie that has a different framerate from the root movie.
This should hopefully handle all of these cases:
run_frame_internalto prevent audio stutter. Close #3817 #3819)I'm thinking something like this: