diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-03-18 21:30:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-03-18 21:30:25 +0300 |
commit | b959dd2e30e1f36c7281013b792861b0ad02647c (patch) | |
tree | eef081e07931a94c404c8d17e466e17d72b72446 /src/soundmanager.cpp | |
parent | b5fead8f53a555b62c9de2dc23b0f2ce9a136e8e (diff) | |
download | mv-b959dd2e30e1f36c7281013b792861b0ad02647c.tar.gz mv-b959dd2e30e1f36c7281013b792861b0ad02647c.tar.bz2 mv-b959dd2e30e1f36c7281013b792861b0ad02647c.tar.xz mv-b959dd2e30e1f36c7281013b792861b0ad02647c.zip |
Add function for test SDL audio features. Now disabled.
Diffstat (limited to 'src/soundmanager.cpp')
-rw-r--r-- | src/soundmanager.cpp | 63 |
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; |