|
Size: 1103
Comment: minor change
|
Size: 1284
Comment: Rewritten
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 17: | Line 17: |
| <<Color2(green,Should SDL_Audio``DeviceID be specifically mentioned like a struct would be although it is a typedef? It has no page.)>> |
|
| Line 21: | Line 19: |
| You can add your code example here | 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. |
| Line 25: | Line 38: |
| Unlocks a previous [[SDL_LockAudioDevice]]() call. The lock manipulated by these functions protects the callback function. During a [[SDL_LockAudioDevice]]()/[[SDL_UnlockAudioDevice]]() pair, you can be guaranteed that the callback function for that device is not running. Do not call these from the callback function or you will cause deadlock. |
Unlocks a previous [[SDL_LockAudioDevice]]() call. Please see [[SDL_LockAudioDevice#Remarks|that function's Remarks]] for more details. |
| Line 32: | Line 41: |
| .[[SDL_LockAudio]] | |
| Line 34: | Line 42: |
| .[[SDL_UnlockAudio]] |
SDL_UnlockAudioDevice
Use this function to unlock the audio callback function for a specified device.
Syntax
void SDL_UnlockAudioDevice(SDL_AudioDeviceID dev)
Function Parameters
dev |
the ID of the device to be unlocked |
Code Examples
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.
Remarks
Unlocks a previous SDL_LockAudioDevice() call. Please see that function's Remarks for more details.
