Use this function to unlock the audio callback function for a specified device.
void SDL_UnlockAudioDevice(SDL_AudioDeviceID dev);
dev | the ID of the device to be unlocked |
This function should be paired with a previous SDL_LockAudioDevice() call.
This function is available since SDL 3.0.0.
void MyAudioCallback(void *userdata, Uint8* stream, int len)
{"The audio callback is running!\n");
printf(0, len); // just silence.
SDL_memset(stream, "The audio callback is done!\n");
printf(
}
// don't lock for 2 seconds at a time in real life, please.
extern SDL_AudioDeviceID devid;
2000); // callback runs for 2 seconds.
SDL_Delay(
SDL_LockAudioDevice(devid);"The audio callback can't be running right now!\n");
printf(2000); // callback doesn't run for 2 seconds.
SDL_Delay("Ok, unlocking!\n");
printf(
SDL_UnlockAudioDevice(devid);2000); // callback runs for 2 seconds. SDL_Delay(