summaryrefslogtreecommitdiff
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
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.
-rw-r--r--src/client.cpp3
-rw-r--r--src/soundmanager.cpp63
-rw-r--r--src/soundmanager.h2
3 files changed, 68 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 7a550d80a..387eaea63 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -523,7 +523,10 @@ void Client::initSoundManager()
try
{
if (config.getBoolValue("sound"))
+ {
+ //soundManager.testAudio();
soundManager.init();
+ }
soundManager.setSfxVolume(config.getIntValue("sfxVolume"));
soundManager.setMusicVolume(config.getIntValue("musicVolume"));
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;
diff --git a/src/soundmanager.h b/src/soundmanager.h
index b00eee0e9..a73975536 100644
--- a/src/soundmanager.h
+++ b/src/soundmanager.h
@@ -51,6 +51,8 @@ class SoundManager final : public ConfigListener
*/
void init();
+ void testAudio();
+
/**
* Removes all sound functionalities.
*/