summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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.
*/