Skip to content

audio: Let apps save an audio stream from destruction during SDL_Quit(). #13244

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 4 commits into from
Jun 23, 2025

Conversation

icculus
Copy link
Collaborator

@icculus icculus commented Jun 21, 2025

This is a special-case piece of functionality, generally these are expected to go away during shutdown, but maybe someone is switching between audio subsystems or something...

This is a special-case piece of functionality, generally these are expected
to go away during shutdown, but maybe someone is switching between audio
subsystems or something...
@icculus icculus added this to the 3.4.0 milestone Jun 21, 2025
@icculus icculus requested a review from slouken June 21, 2025 01:19
@slouken
Copy link
Collaborator

slouken commented Jun 21, 2025

    SDL_zero(current_audio);

Hmmm...

@slouken
Copy link
Collaborator

slouken commented Jun 21, 2025

Maybe we can add a test case to validate this functionality?

@madebr
Copy link
Contributor

madebr commented Jun 21, 2025

What if the requested audio back end changes between quit and init? Or is that of no concern?

@slouken
Copy link
Collaborator

slouken commented Jun 21, 2025

After sleeping on it, I'm inclined to think that audio streams are the audio equivalent of SDL surfaces and shouldn't be automatically cleaned up unless they're bound to devices.

@slouken
Copy link
Collaborator

slouken commented Jun 21, 2025

If we do want this, I updated the PR to just orphan the streams rather than try to keep them in the list for the next audio open.

@icculus
Copy link
Collaborator Author

icculus commented Jun 21, 2025

What if the requested audio back end changes between quit and init? Or is that of no concern?

There isn't any backend-specific code in an audio stream...even being bound to a device just means the device thread pulls from the stream.

@icculus
Copy link
Collaborator Author

icculus commented Jun 21, 2025

After sleeping on it, I'm inclined to think that audio streams are the audio equivalent of SDL surfaces and shouldn't be automatically cleaned up unless they're bound to devices

That's an ABI break, though (and more confusing, because sometimes they go away and sometimes they don't).

@icculus
Copy link
Collaborator Author

icculus commented Jun 21, 2025

If we do want this, I updated the PR to just orphan the streams rather than try to keep them in the list for the next audio open.

Yeah, this is better.

@slouken
Copy link
Collaborator

slouken commented Jun 21, 2025

After sleeping on it, I'm inclined to think that audio streams are the audio equivalent of SDL surfaces and shouldn't be automatically cleaned up unless they're bound to devices

That's an ABI break, though (and more confusing, because sometimes they go away and sometimes they don't).

Yep, agreed.

@slouken
Copy link
Collaborator

slouken commented Jun 21, 2025

And then we'll set this property in the new SDL_mixer for streams not associated with a device?

@icculus
Copy link
Collaborator Author

icculus commented Jun 22, 2025

Yeah, that's the plan.

Should we merge this, then, or is there more to do?

@slouken
Copy link
Collaborator

slouken commented Jun 22, 2025

I’m still mulling over the name… persist on shutdown? Auto cleanup = false? But we can squash and merge as-is.

@slouken slouken merged commit 274aa02 into libsdl-org:main Jun 23, 2025
41 checks passed
@slouken
Copy link
Collaborator

slouken commented Jun 23, 2025

I went ahead and renamed SDL_PROP_AUDIOSTREAM_KEEP_ON_SHUTDOWN_BOOLEAN to SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN. Let me know if you disagree!

@icculus icculus deleted the sdl3-audiostream-keep-on-shutdown branch June 23, 2025 13:23
@icculus
Copy link
Collaborator Author

icculus commented Jun 23, 2025

lgtm, I'll put this in SDL_remixer.

@icculus
Copy link
Collaborator Author

icculus commented Jun 23, 2025

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.

3 participants