Forráskód Böngészése

If SDL initialization fails, the background will still start but show an error to let the user know why the sound doesn't work

Signed-off-by: Alexis Maiquez Murcia <almamu@almamu.com>
Alexis Maiquez Murcia 4 éve
szülő
commit
3ed1459568
2 módosított fájl, 15 hozzáadás és 8 törlés
  1. 9 4
      .github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md
  2. 6 4
      main.cpp

+ 9 - 4
.github/ISSUE_TEMPLATE/background-doesn-t-load-properly.md

@@ -8,19 +8,24 @@ assignees: Almamu
 
 ---
 
-**Wallpaper Engine Background**
-A link to the background in the steam workshop or it's background ID.
+**Wallpaper Engine Background(s)**
+
+Link(s) to the backgorund(s) in the steam workshop or their background ID(s).
 
 **Console output**
+
 When a background cannot be loaded It's usually due to some unexpected error that is logged into the terminal. Please attach the program's output so we can properly debug it if needed.
 
 **Screenshots**
+
 If you have any screenshot of it working on Windows that'll help so we can compare both outputs
 
 **Desktop (please complete the following information):**
- - OS: [e.g. Arch Linux]
+ 
+- OS: [e.g. Arch Linux]
  - Desktop Environment: [e.g. GNOME, CINNAMON, KDE...]
  - Window Manager: [if in doubt, just leave it empty]
 
 **Additional context**
-Any additional information about your setup (like
+
+Any additional information about your setup

+ 6 - 4
main.cpp

@@ -345,12 +345,14 @@ int main (int argc, char* argv[])
         {
             // Mix_GetError is an alias for SDL_GetError, so calling it directly will yield the correct result
             // it doesn't matter if SDL_Init or Mix_Init failed, both report the errors through the same functions
-            fprintf (stderr, "Cannot initialize SDL audio system, SDL_GetError: %s", SDL_GetError ());
-            return 2;
+            std::cerr << "Cannot initialize SDL audio system, SDL_GetError: " << SDL_GetError() << std::endl;
+            std::cerr << "Continuing without audio support" << std::endl;
+            shouldEnableAudio = false;
         }
 
-        // initialize audio engine
-        Mix_OpenAudio (22050, AUDIO_S16SYS, 2, 640);
+        // initialize audio engine if it should be
+        if (shouldEnableAudio)
+            Mix_OpenAudio (22050, AUDIO_S16SYS, 2, 640);
     }
 
     // TODO: FIGURE OUT THE REQUIRED INPUT MODE, AS SOME WALLPAPERS USE THINGS LIKE MOUSE POSITION