adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[adonthell-commits] master b32a5e1 2/4: CHECK that we can play back ogg


From: Kai Sterker
Subject: [adonthell-commits] master b32a5e1 2/4: CHECK that we can play back ogg vorbis or else print a warning
Date: Sat, 30 Sep 2017 18:27:32 -0400 (EDT)

branch: master
commit b32a5e1b4469b703e92efc6003fab9ef44925056
Author: Kai Sterker <address@hidden>
Commit: Kai Sterker <address@hidden>

    CHECK that we can play back ogg vorbis or else print a warning
---
 src/audio.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/audio.cc b/src/audio.cc
index 3c6a24a..87c9cca 100644
--- a/src/audio.cc
+++ b/src/audio.cc
@@ -89,6 +89,13 @@ void audio::init (config *myconfig) {
       music_file[i] = "";
   }
   
+  // Check if we can playback music
+  if (!Mix_Init(MIX_INIT_OGG))
+  {
+      fprintf(stderr, "Unable to init Ogg Vorbis: %s\n", SDL_GetError());
+      fprintf(stderr, "Music will not be available.\n");
+  }
+
   // Try opening the audio device at our defaults
   i = Mix_OpenAudio(audio_rate, audio_format, audio_channels, buffer_size);
 
@@ -219,6 +226,7 @@ void audio::set_background_volume(int volume) {
     background_volume = volume;
 
   // Scales 0-100% to 0-128
+  // Mix_Volume(-1, int(background_volume * 1.28));
   Mix_VolumeMusic(int(background_volume * 1.28));
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]