Skip to content

audio: Added SDL_PutAudioStreamDataNoCopy. #13118

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

Merged
merged 1 commit into from
May 26, 2025

Conversation

icculus
Copy link
Collaborator

@icculus icculus commented May 25, 2025

This allows an app to add data to an audio stream without an allocating a copy, if they are maintaining the data elsewhere.

@slouken
Copy link
Collaborator

slouken commented May 25, 2025

I’m not sure about the name, it almost implies that since it’s const, then you’re going to make a copy of it.

@maia-s
Copy link
Contributor

maia-s commented May 25, 2025

SDL_PutAudioStreamDataReference?

@icculus
Copy link
Collaborator Author

icculus commented May 25, 2025

SDL_PutAudioStreamDataPointer? SDL_PutAudioStreamExternalData?

@maia-s
Copy link
Contributor

maia-s commented May 25, 2025

SDL_PutAudioStreamZeroCopyData works too (tho ig it gets copied eventually?)
Maybe NoCopy instead of ZeroCopy
or DataNoCopy instead of NoCopyData

@icculus
Copy link
Collaborator Author

icculus commented May 25, 2025

Renamed it to SDL_PutAudioStreamDataPointer, added a callback that fires when the buffer is totally consumed (safe to free or reuse), so you don't have to guess.

@slouken
Copy link
Collaborator

slouken commented May 25, 2025

I'm still on the fence on the naming, but conceptually the idea is great.

@slouken
Copy link
Collaborator

slouken commented May 25, 2025

SDL_PutAudioStreamDataPointer() makes you wonder if the other function doesn't take a pointer.
SDL_PutAudioStreamExternalData() is not bad, what about SDL_PutAudioStreamStaticData()?

@icculus
Copy link
Collaborator Author

icculus commented May 26, 2025

Sam and I discussed this and we're going with SDL_PutAudioStreamDataNoCopy. We don't have (afaict) anything else in SDL that maps to the same concept; usually we'll copy data when we need it past the end of an API call, so we don't have any other naming scheme to match.

@icculus icculus force-pushed the sdl3-putaudiostreamconstdata branch from 250c652 to 0e11bda Compare May 26, 2025 04:05
@icculus
Copy link
Collaborator Author

icculus commented May 26, 2025

This is rebased with the new name, so if the builders like it and everyone is happy, we can merge it.

@icculus icculus changed the title audio: Added SDL_PutAudioStreamConstData. audio: Added SDL_PutAudioStreamDataNoCopy. May 26, 2025
@icculus icculus merged commit 5e50d39 into libsdl-org:main May 26, 2025
41 checks passed
@icculus icculus deleted the sdl3-putaudiostreamconstdata branch May 26, 2025 16:34
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.

4 participants