SDL_AudioSpec Struct Reference
#include <SDL_audio.h>
Detailed Description
When filling in the desired audio spec structure,
- 'desired->freq' should be the desired audio frequency in samples-per-second.
- 'desired->format' should be the desired audio format.
- 'desired->samples' is the desired size of the audio buffer, in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8096 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq
- 'desired->size' is the size in bytes of the audio buffer, and is calculated by SDL_OpenAudio().
- 'desired->silence' is the value used to set the buffer to silence, and is calculated by SDL_OpenAudio().
- 'desired->callback' should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio() and SDL_UnlockAudio() in your code.
- 'desired->userdata' is passed as the first parameter to your callback function.
- Note:
- The calculated values in this structure are calculated by SDL_OpenAudio()
Member Function Documentation
void |
( |
SDLCALL * |
callback |
) |
|
This function is called when the audio device needs more data.
- Parameters:
-
[out] | stream | A pointer to the audio data buffer |
[in] | len | The length of the audio buffer in bytes. |
Once the callback returns, the buffer will no longer be valid. Stereo samples are stored in a LRLRLR ordering.
Field Documentation
Number of channels: 1 mono, 2 stereo
DSP frequency -- samples per second
Necessary for some compile environments
Audio buffer size in samples (power of 2)
Audio buffer silence value (calculated)
Audio buffer size in bytes (calculated)
The documentation for this struct was generated from the following file: