-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
AudioStream(Playback)WAV: Use LocalVectors instead of pointers #96017
Conversation
Does anyone know if using Vector instead of pointers causes audio corruption? I don't understand why AudioStreamMP3 doesn't match AudioStreamWAV and AudioStreamPlaybackWAV. |
Most of audio playback works in two ways. In case of uncompressed (WAV 8/16 bit) it simply copies samples from the data, converts into 32 bit float, then goes into the audio buffer. And with compressed (MP3, QOA, IMA ADPCM) the data goes through a decode process before being sent to the buffer. All access uses some kind of The only change with this PR is how data is stored in memory. Everything is passed to buffer/decoders using the Vector's pointer anyway, with the advantage of not having explicit Shouldn't cause corruption at all. |
One thing I noticed: |
Rebased on top of master following #95463 merge. |
6289213
to
2816e87
Compare
80f7b12
to
2fda1f3
Compare
One last force push. Forgot to set all values in the vector to 0 when setting data, this was causing an audible pop when looping a 16-bit stream. |
Thanks! |
This PR originally used
Vector
s, but were changed toLocalVector
s on reduz's request.Changes the types of (
AudioStreamPlaybackWAV::qoa.dec
andAudioStreamWAV::data
) to use Vectors instead of pointers. This was done withAudioStreamMP3
'sdata
between versions 3.x and 4.x of Godot.Only private variables and function structures were modified, without altering return type, therefore does not break compatibility.
Alongside #95463, this PR makes the
AudioStreamWAV
andAudioStreamPlaybackWAV
classes free of directmemalloc/free
calls, and consequently the onlymemalloc/free
calls within the/scene
directory.