diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-09-15 01:29:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-09-15 01:29:38 +0300 |
commit | ae01890fb7661acfb94bd9a51b5269c6ada2c66b (patch) | |
tree | fa925a19b22f9dc41fdbb6a738d28d1098dc30ff /src | |
parent | 69f995bb5124c19746ff026f4e64c7398611e9f0 (diff) | |
download | manaplus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.tar.gz manaplus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.tar.bz2 manaplus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.tar.xz manaplus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.zip |
Add option for change number of max parallel sounds.
Diffstat (limited to 'src')
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_audio.cpp | 4 | ||||
-rw-r--r-- | src/soundmanager.cpp | 11 | ||||
-rw-r--r-- | src/soundmanager.h | 2 |
4 files changed, 17 insertions, 1 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 5dade038f..5dad898dd 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -418,6 +418,7 @@ void setConfigDefaults(Configuration &cfg) AddDEF("sdlLogLevel", 0); AddDEF("allowHighDPI", false); AddDEF("sdlDriver", ""); + AddDEF("parallelAudioChannels", 16); } void setConfigDefaults2(Configuration &cfg) diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index bd8097318..6275ff59a 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -107,6 +107,10 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : MainConfig_true, DoNotAlign_false); + // TRANSLATORS: settings option + new SetupItemIntTextField(_("Parallel number of sounds"), "", + "parallelAudioChannels", this, "parallelAudioChannelsEvent", 1, 1000); + // TRANSLATORS: settings group new SetupItemLabel(_("Sound effects"), "", this); diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index 37a6321a7..a4ee3acee 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -117,6 +117,8 @@ void SoundManager::optionChanged(const std::string &value) mFadeoutMusic = (config.getIntValue("fadeoutmusic") != 0); else if (value == "uselonglivesounds") mCacheSounds = (config.getIntValue("uselonglivesounds") != 0); + else if (value == "parallelAudioChannels") + setChannels(config.getIntValue("parallelAudioChannels")); } void SoundManager::init() @@ -142,6 +144,7 @@ void SoundManager::init() config.addListener("musicVolume", this); config.addListener("fadeoutmusic", this); config.addListener("uselonglivesounds", this); + config.addListener("parallelAudioChannels", this); if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) { @@ -176,7 +179,7 @@ void SoundManager::init() logger->log("Fallback to stereo audio"); } - Mix_AllocateChannels(16); + Mix_AllocateChannels(config.getIntValue("parallelAudioChannels")); Mix_VolumeMusic(mMusicVolume); Mix_Volume(-1, mSfxVolume); @@ -570,3 +573,9 @@ void SoundManager::volumeRestore() const Mix_Volume(-1, mSfxVolume); } } + +void SoundManager::setChannels(const int channels) const +{ + if (mInstalled) + Mix_AllocateChannels(channels); +} diff --git a/src/soundmanager.h b/src/soundmanager.h index 01c2d5627..f4dca4cd1 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -142,6 +142,8 @@ class SoundManager final : public ConfigListener void shutdown(); + void setChannels(const int channels) const; + private: /** Logs various info about sound device. */ static void info(); |