git repos / saland

commit 81ced75f

Poul Sander · 2021-06-01 19:18
81ced75ffeaa56da6538c624886ffb64bf4d6e87 patch · browse files
parent 8ed0dc99608a98f8d4dc727823458be6ade98181

Init sound system

Changed files

M src/saland.cpp before
diff --git a/src/saland.cpp b/src/saland.cpp index 39ebac3..894fb87 100644 --- a/src/saland.cpp +++ b/src/saland.cpp
@@ -302,6 +302,14 @@ void runGame() {
IMG_Init(IMG_INIT_PNG);
TTF_Init();
Mix_Init(MIX_INIT_OGG);
+ if (!globalData.NoSound) {
+ //If sound has not been disabled, then load the sound system
+ if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0) {
+ std::cerr << "Warning: Couldn't set 44100 Hz 16-bit audio - Reason: " << SDL_GetError() << "\n"
+ << "Sound will be disabled!" << "\n";
+ globalData.NoSound = true; //Tries to stop all sound from playing/loading
+ }
+ }
int rendererFlags = 0;