Use this function to unlock the audio callback function for a specified device.
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)
{
printf("The audio callback is running!\n");
SDL_memset(stream, 0, len); // just silence.
printf("The audio callback is done!\n");
}
// don't lock for 2 seconds at a time in real life, please.
extern SDL_AudioDeviceID devid;
SDL_Delay(2000); // callback runs for 2 seconds.
SDL_LockAudioDevice(devid);
printf("The audio callback can't be running right now!\n");
SDL_Delay(2000); // callback doesn't run for 2 seconds.
printf("Ok, unlocking!\n");
SDL_UnlockAudioDevice(devid);
SDL_Delay(2000); // callback runs for 2 seconds.