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.
(This is just about ready to merge, but it's a gigantic change and I need to, at a minimum, get the buildbots happy with it again, so this is still a draft.)
This is the rewrite of the audio converters, the first big step towards what I envision for SDL3's audio subsystem.
SDL_AudioCVT is gone, even internally.
There is an internal function called ConvertAudio(), which does all the work of SDL_AudioCVT except resampling. ResampleAudio() does that. The two are combined in SDL_AudioStream.
libsamplerate is gone.
I suspect our resampler is finally Good Enough, knock on wood. Most people never used the libsamplerate support; even if it was compiled in and available at runtime, you had to force it with an SDL hint to enable it. This was always meant to be an in-case-of-emergency fallback, and it complicated the conversion code to have an abstract interface to support the option, so I yanked it. If we need to, we can put it back in, but I'm hoping we don't need to.
Cleanups and improvements to audio conversion interfaces.
Just a lot of simplification and tweaks across the board.
SDL_AudioStream can now change its output format/rate/channels on the fly!
I buried the lede, this part is awesome. I need this for the Big Plans for SDL3 audio, but even in normal app use, it's fun to change an audiostream's sample rate on the fly, like this program does:
sdl3-dynamic-audiostream.mp4
Resamples in chunks work correctly now.
Issue #7358 is gone, the redesign fixed it; feed the same data in blocks or as one big blob and the final output will have the same checksum.
Still TODO:
I added a ton of FIXMEs (both to this work and other things I saw as I moved around in this code). Notably, AudioStreams allocate a much larger work buffer than they probably need, just for laziness at the moment. We can calculate that more carefully.
Valgrind saw an off-by-one issue I need to track down, too.
Related issues
Fixes #7378
Fixes #7358
Reference Issue #6632
(Maybe others, too.)