Skip to main content

SDL_AudioPostmixCallback

Type Alias SDL_AudioPostmixCallback 

Source
pub type SDL_AudioPostmixCallback = Option<unsafe extern "C" fn(userdata: *mut c_void, spec: *const SDL_AudioSpec, buffer: *mut f32, buflen: c_int)>;
Expand description

A callback that fires when data is about to be fed to an audio device.

This is useful for accessing the final mix, perhaps for writing a visualizer or applying a final effect to the audio data before playback.

This callback should run as quickly as possible and not block for any significant time, as this callback delays submission of data to the audio device, which can cause audio playback problems.

The postmix callback must be able to handle any audio data format specified in spec, which can change between callbacks if the audio device changed. However, this only covers frequency and channel count; data is always provided here in SDL_AUDIO_F32 format.

The postmix callback runs after logical device gain and audiostream gain have been applied, which is to say you can make the output data louder at this point than the gain settings would suggest.

Parameter: userdata a pointer provided by the app through SDL_SetAudioPostmixCallback, for its own use. Parameter: spec the current format of audio that is to be submitted to the audio device. Parameter: buffer the buffer of audio samples to be submitted. The callback can inspect and/or modify this data. Parameter: buflen the size of buffer in bytes.

Thread Safety: This will run from a background thread owned by SDL. The application is responsible for locking resources the callback touches that need to be protected.

Available Since: This datatype is available since SDL 3.2.0.

See Also: SDL_SetAudioPostmixCallback

Aliased Type§

pub enum SDL_AudioPostmixCallback {
    None,
    Some(unsafe extern "C" fn(*mut c_void, *const SDL_AudioSpec, *mut f32, i32)),
}

Variants§

§1.0.0

None

No value.

§1.0.0

Some(unsafe extern "C" fn(*mut c_void, *const SDL_AudioSpec, *mut f32, i32))

Some value of type T.