summaryrefslogtreecommitdiff
path: root/src/soundmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-18 21:30:25 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-18 21:30:25 +0300
commitb959dd2e30e1f36c7281013b792861b0ad02647c (patch)
treeeef081e07931a94c404c8d17e466e17d72b72446 /src/soundmanager.cpp
parentb5fead8f53a555b62c9de2dc23b0f2ce9a136e8e (diff)
downloadmanaverse-b959dd2e30e1f36c7281013b792861b0ad02647c.tar.gz
manaverse-b959dd2e30e1f36c7281013b792861b0ad02647c.tar.bz2
manaverse-b959dd2e30e1f36c7281013b792861b0ad02647c.tar.xz
manaverse-b959dd2e30e1f36c7281013b792861b0ad02647c.zip
Add function for test SDL audio features. Now disabled.
Diffstat (limited to 'src/soundmanager.cpp')
-rw-r--r--src/soundmanager.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp
index 7e4645dfd..fa470e3af 100644
--- a/src/soundmanager.cpp
+++ b/src/soundmanager.cpp
@@ -175,6 +175,69 @@ void SoundManager::init()
playMusic(mCurrentMusicFile);
}
+void SoundManager::testAudio()
+{
+ mPlayBattle = config.getBoolValue("playBattleSound");
+ mPlayGui = config.getBoolValue("playGuiSound");
+ mPlayMusic = config.getBoolValue("playMusic");
+ mFadeoutMusic = config.getBoolValue("fadeoutmusic");
+ mMusicVolume = config.getIntValue("musicVolume");
+ mSfxVolume = config.getIntValue("sfxVolume");
+ mCacheSounds = config.getIntValue("uselonglivesounds");
+
+ const size_t audioBuffer = 4096;
+ int channels = config.getIntValue("audioChannels");
+ switch (channels)
+ {
+ case 3:
+ channels = 4;
+ break;
+ case 4:
+ channels = 6;
+ break;
+ default:
+ break;
+ }
+
+ SDL_AudioSpec desired;
+ SDL_AudioSpec actual;
+
+ desired.freq = config.getIntValue("audioFrequency");
+ desired.format = MIX_DEFAULT_FORMAT;
+ desired.channels = channels;
+ desired.samples = audioBuffer;
+ desired.callback = nullptr;
+ desired.userdata = nullptr;
+
+ if (SDL_OpenAudio(&desired, &actual) < 0)
+ {
+ logger->log("SoundManager::testAudio error: %s",
+ Mix_GetError());
+ return;
+ }
+ if (desired.freq != actual.freq)
+ {
+ logger->log("SoundManager::testAudio frequence: %d -> %d",
+ actual.freq, desired.freq);
+ }
+ if (desired.format != actual.format)
+ {
+ logger->log("SoundManager::testAudio format: %d -> %d",
+ actual.format, desired.format);
+ }
+ if (desired.channels != actual.channels)
+ {
+ logger->log("SoundManager::testAudio channels: %d -> %d",
+ actual.channels, desired.channels);
+ }
+ if (desired.samples != actual.samples)
+ {
+ logger->log("SoundManager::testAudio samples: %d -> %d",
+ actual.samples, desired.samples);
+ }
+ SDL_CloseAudio();
+}
+
void SoundManager::info()
{
SDL_version compiledVersion;