Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't stop audio streams in run_frame_internal to prevent audio stutter. Close #3817 #3819

Closed
wants to merge 1 commit into from

Conversation

desuwa
Copy link
Contributor

@desuwa desuwa commented Mar 27, 2021

Related issue #3817

This seems safe to do since sound instances will still get pruned normally by the audio manager once they have finished playing, as far as I understand.

@desuwa desuwa changed the title Don't stop audio streams in run_frame_internal to prevent audio stutter. Don't stop audio streams in run_frame_internal to prevent audio stutter. Close #3817 Mar 27, 2021
Copy link

@seanpm2001 seanpm2001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, explanation makes sense. Let's see if this actually fixes the problem.

@Herschel
Copy link
Member

Herschel commented Apr 8, 2021

This code is handling the case where there is a legit gap in streaming audio, such as the following example:
sound_gap.zip
With these changes, the second audio clip will play too soon, immediately after the first clip.

As you note, high framerate movies will often get SoundStreamBlock tags clumped together into alternating frames, but you can also have gaps in the track itself, which will also appear as a large region missing SoundStreamBlock tags. I'm not 100% sure how Flash handles or differentiates these cases, hence the uncertainty in the original comments.

Perhaps this should only stop the sound if there are several (2? 3?) frames without a SoundStreamBlock, instead of a single frame.

Flash itself also does weird/buggy things when this occurs. For example, here's the above SWF with the stream bitrate set to 8kbps. The official Flash Player will play it with a gap, but too small of a gap -- it will play too soon and appear out of sync.
sound_gap2.zip
This specifically tends to occur with MP3 encoding.
The old-school workaround that animators used was to add a layer with a silent repeated sound, so that there were no gaps in the streaming audio.

@desuwa
Copy link
Contributor Author

desuwa commented Apr 9, 2021

Ah, right. So the stream is actually just like a normal sound with all the data already available and the playback starts at the first first SoundStreamBlock.
I thought the samples were enqueued and played back on the fly as the movie was being played so gaps wouldn't be a problem in this case.

I'm going to close this I guess as it's probably not fixable without changing how streams work :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants