What is difference between Mix_Init and Mix_OpenAudio SDL?

1.4k views Asked by At

I've seen many tutorials for SDL_mixer but none of them use the Mix_Init function. I saw this Mix_Init function on the documentation page: https://web.archive.org/web/20210615233017/https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html

The tutorials only used a function called Mix_OpenAudio for initializing SDL_mixer.

If I call the function Mix_OpenAudio, will it automatically call the function Mix_Init? Is Mix_Init function is only some type of checker function?

1

There are 1 answers

0
keltar On

Check the documentation at https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_9.html :

Initialize by loading support as indicated by the flags, or at least return success if support is already loaded. You may call this multiple times, which will actually require you to call Mix_Quit just once to clean up. You may call this function with a 0 to retrieve whether support was built-in or not loaded yet.

If you need support for compressed audio formats like flac, mp3, ogg vorbis - you need to call this function with list of formats you need. I'll result in loading required code to decompress that formats, if it isn't built into SDL_mixer. If you only use WAV you may omit Mix_Init call.