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

SDL_AudioStream should be able to change output formats #7378

Closed
icculus opened this issue Feb 28, 2023 · 2 comments · Fixed by #7571
Closed

SDL_AudioStream should be able to change output formats #7378

icculus opened this issue Feb 28, 2023 · 2 comments · Fixed by #7571
Assignees
Milestone

Comments

@icculus
Copy link
Collaborator

icculus commented Feb 28, 2023

Ok, so thinking about this more, the problem is that SDL_AudioStream doesn't let you change output formats once you create it, but that's because we convert data as it is input. But this is silly, we should be queuing it up and converting it as we need output. This would let us do a couple of things:

  • You could deal with an audio device that you're feeding if it changes formats.
  • You can change a stream's sample rate for various pitch effects on the fly.
  • You could potentially have access to more resampling history at the moment you need it.
  • You don't spend the CPU time converting audio that you might throw away anyhow with SDL_ClearAudioStream/SDL_DestroyAudioStream.

Originally posted by @icculus in #6632 (comment)

@icculus icculus self-assigned this Feb 28, 2023
@icculus icculus added this to the 3.2.0 milestone Feb 28, 2023
@icculus
Copy link
Collaborator Author

icculus commented Mar 1, 2023

Working on this now.

@icculus
Copy link
Collaborator Author

icculus commented Mar 2, 2023

Ah, I remember another reason why this converts/resamples during Put and not during Get.

It wasn't clear we could definitely say that there would be X samples available (if the resample ratio was weird we might estimate incorrectly), so it was easier to say "the converted data queue definitely has X bytes available for reading right now" instead of "there will be X bytes available if we converted everything currently available."

We can probably overcome this, though.

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 a pull request may close this issue.

1 participant