Close a previously-opened audio device.
Defined in <SDL3/SDL_audio.h>
void SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
SDL_AudioDeviceID | devid | an audio device id previously returned by SDL_OpenAudioDevice(). |
The application should close open audio devices once they are no longer needed.
This function may block briefly while pending audio data is played by the hardware, so that applications don't drop the last buffer of data they supplied if terminating immediately afterwards.
It is safe to call this function from any thread.
This function is available since SDL 3.1.3.
extern SDL_AudioSpec want;
SDL_AudioDeviceID devid = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &want);if (devid != 0) {
SDL_ResumeAudioDevice(devid);5000); // let device play for 5 seconds
SDL_Delay(
SDL_CloseAudioDevice(devid); }