[][src]Function sdl2_sys::SDL_LoadWAV_RW

pub unsafe extern "C" fn SDL_LoadWAV_RW(
    src: *mut SDL_RWops,
    freesrc: c_int,
    spec: *mut SDL_AudioSpec,
    audio_buf: *mut *mut Uint8,
    audio_len: *mut Uint32
) -> *mut SDL_AudioSpec

\brief Load the audio data of a WAVE file into memory

Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len to be valid pointers. The entire data portion of the file is then loaded into memory and decoded if necessary.

If \c freesrc is non-zero, the data source gets automatically closed and freed before the function returns.

Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and µ-law (8 bits). Other formats are currently unsupported and cause an error.

If this function succeeds, the pointer returned by it is equal to \c spec and the pointer to the audio data allocated by the function is written to \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec members \c freq, \c channels, and \c format are set to the values of the audio data in the buffer. The \c samples member is set to a sane default and all others are set to zero.

It's necessary to use SDL_FreeWAV() to free the audio data returned in \c audio_buf when it is no longer used.

Because of the underspecification of the Waveform format, there are many problematic files in the wild that cause issues with strict decoders. To provide compatibility with these files, this decoder is lenient in regards to the truncation of the file, the fact chunk, and the size of the RIFF chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the loading process.

Any file that is invalid (due to truncation, corruption, or wrong values in the headers), too big, or unsupported causes an error. Additionally, any critical I/O error from the data source will terminate the loading process with an error. The function returns NULL on error and in all cases (with the exception of \c src being NULL), an appropriate error message will be set.

It is required that the data source supports seeking.

Example: \code SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); \endcode

\param src The data source with the WAVE data \param freesrc A integer value that makes the function close the data source if non-zero \param spec A pointer filled with the audio format of the audio data \param audio_buf A pointer filled with the audio data allocated by the function \param audio_len A pointer filled with the length of the audio data buffer in bytes \return NULL on error, or non-NULL on success.