1

I saw many tutorial of SDL_mixer but none of them are used Mix_Init function. I saw this Mix_Init function on the documentation page https://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer.html

The tutorials are only used the function called Mix_OpenAudio for initialize SDL_mixer.

My question is that Is if I call the function Mix_OpenAudio, it automatically call the function Mix_Init or there is no need to call the function Mix_Init.

Is Mix_Init function is only some type of checker function.

genpfault
  • 51,148
  • 11
  • 85
  • 139
NinjaGameDev
  • 73
  • 2
  • 7

1 Answers1

1

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.

keltar
  • 17,711
  • 2
  • 37
  • 42