Skip to main content

SDL_ConvertAudioSamples

Function SDL_ConvertAudioSamples 

Source
pub unsafe extern "C" fn SDL_ConvertAudioSamples(
    src_spec: *const SDL_AudioSpec,
    src_data: *const Uint8,
    src_len: c_int,
    dst_spec: *const SDL_AudioSpec,
    dst_data: *mut *mut Uint8,
    dst_len: *mut c_int,
) -> bool
Expand description

Convert some audio data of one format to another format.

Please note that this function is for convenience, but should not be used to resample audio in blocks, as it will introduce audio artifacts on the boundaries. You should only use this function if you are converting audio data in its entirety in one call. If you want to convert audio in smaller chunks, use an SDL_AudioStream, which is designed for this situation.

Internally, this function creates and destroys an SDL_AudioStream on each use, so it’s also less efficient than using one directly, if you need to convert multiple times.

Parameter: src_spec the format details of the input audio. Parameter: src_data the audio data to be converted. Parameter: src_len the len of src_data. Parameter: dst_spec the format details of the output audio. Parameter: dst_data will be filled with a pointer to converted audio data, which should be freed with SDL_free(). On error, it will be NULL. Parameter: dst_len will be filled with the len of dst_data. Returns: true on success or false on failure; call SDL_GetError() for more information.

Thread Safety: It is safe to call this function from any thread.

Available Since: This function is available since SDL 3.2.0.