|
Size: 1145
Comment: minor change
|
Size: 1832
Comment: Rewritten.
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 11: | Line 11: |
| void SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on) |
void SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on) |
| Line 19: | Line 18: |
| <<Color2(green,Should SDL_Audio``DeviceID be specifically mentioned like a struct would be although it is a typedef? It has no page.)>> |
|
| Line 23: | Line 20: |
| You can add your code example here | SDL_PauseAudioDevice(devid, 1); // audio callback is stopped when this returns. SDL_Delay(5000); // audio device plays silence for 5 seconds SDL_PauseAudio(devid, 0); // audio callback starts running again. |
| Line 27: | Line 26: |
| This function pauses and unpauses the audio callback processing. It should be called with '''pause_on'''=0 after opening the specified audio device to start playing sound. This is so you can safely initialize data for your callback function after opening the audio device. Silence will be written to the audio device during the pause. | This function pauses and unpauses the audio callback processing for a given device. Newly-opened audio devices start in the paused state, so you must call this function with '''pause_on'''=0 after opening the specified audio device to start playing sound. This allows you to safely initialize data for your callback function after opening the audio device. Silence will be written to the audio device while paused, and the audio callback is guaranteed to not be called. Pausing one device does not prevent other unpaused devices from running their callbacks. Pausing state does not stack; even if you pause a device several times, a single unpause will start the device playing again, and vice versa. This is different than how [[SDL_LockAudioDevice]]() works. If you just need to protect a few variables from race conditions vs your callback, you shouldn't pause the audio device, as it will lead to dropouts in the audio playback. Instead, you should use [[SDL_LockAudioDevice]](). |
| Line 30: | Line 33: |
| .[[SDL_PauseAudio]] | .[[SDL_UnpauseAudioDevice]] .[[SDL_LockAudioDevice]] |
SDL_PauseAudioDevice
Use this function to pause and unpause audio playback on a specified device.
Syntax
void SDL_PauseAudioDevice(SDL_AudioDeviceID dev, int pause_on)
Function Parameters
dev |
a device opened by SDL_OpenAudioDevice() |
pause_on |
non-zero to pause, 0 to unpause |
Code Examples
SDL_PauseAudioDevice(devid, 1); // audio callback is stopped when this returns.
SDL_Delay(5000); // audio device plays silence for 5 seconds
SDL_PauseAudio(devid, 0); // audio callback starts running again.
Remarks
This function pauses and unpauses the audio callback processing for a given device. Newly-opened audio devices start in the paused state, so you must call this function with pause_on=0 after opening the specified audio device to start playing sound. This allows you to safely initialize data for your callback function after opening the audio device. Silence will be written to the audio device while paused, and the audio callback is guaranteed to not be called. Pausing one device does not prevent other unpaused devices from running their callbacks.
Pausing state does not stack; even if you pause a device several times, a single unpause will start the device playing again, and vice versa. This is different than how SDL_LockAudioDevice() works.
If you just need to protect a few variables from race conditions vs your callback, you shouldn't pause the audio device, as it will lead to dropouts in the audio playback. Instead, you should use SDL_LockAudioDevice().
