summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-09-15 01:29:38 +0300
committerAndrei Karas <akaras@inbox.ru>2017-09-15 01:29:38 +0300
commitae01890fb7661acfb94bd9a51b5269c6ada2c66b (patch)
treefa925a19b22f9dc41fdbb6a738d28d1098dc30ff
parent69f995bb5124c19746ff026f4e64c7398611e9f0 (diff)
downloadplus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.tar.gz
plus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.tar.bz2
plus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.tar.xz
plus-ae01890fb7661acfb94bd9a51b5269c6ada2c66b.zip
Add option for change number of max parallel sounds.
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/gui/widgets/tabs/setup_audio.cpp4
-rw-r--r--src/soundmanager.cpp11
-rw-r--r--src/soundmanager.h2
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();