Fix a pop on play() in AudioStreamPlayer2D and 3D #46151
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Successor to #46078.
This fixes pops by ensuring that audio stream players start their playback streams before attempting to mix them. This issue was introduced in 016f7bd and causes _mix_audio() to occasionally attempt to mix using a playback stream before the physics process notification has properly started it. Specifically, if
setseek
is left unset, the audio stream playback's start() method will never be called. If you're having difficulty reproducing the pop that this fixes, try halving your physics framerate until you can repro it.In addition to reverting the change referenced above, I added some logic so I don't reintroduce the issue it fixed.
While I think it fixes the worst of the pops, I'm not sure if it would be appropriate to call #22016 completely solved with it, since there may be other issues. AudioStreamPlayer2D and 3D still have pops on stop() but they sound just as clean at the beginning of playback as a regular AudioStreamPlayer now.
To test, download this sample project.
new_test_project.zip
Run the test project and select the options to play an OGG or MP3 using both 3D and 2D player nodes. WAV files will be unaffected because they don't need to be started before being used.