summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-21 03:26:29 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-21 03:26:29 +0300
commitd83a092ae6271c78a66e1ef3de6e6f6eb40a566e (patch)
tree454a8f6abc314ceb717b73fd5ee676efa9768c4c
parent188bfbdc024afe71be191d17a12bf5bf12077065 (diff)
downloadmanaplus-d83a092ae6271c78a66e1ef3de6e6f6eb40a566e.tar.gz
manaplus-d83a092ae6271c78a66e1ef3de6e6f6eb40a566e.tar.bz2
manaplus-d83a092ae6271c78a66e1ef3de6e6f6eb40a566e.tar.xz
manaplus-d83a092ae6271c78a66e1ef3de6e6f6eb40a566e.zip
Add audio frequency and audio channels settings.
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/gui/setup_audio.cpp16
-rw-r--r--src/gui/setup_audio.h3
-rw-r--r--src/sound.cpp17
4 files changed, 35 insertions, 3 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 5b4641f1a..6933c7356 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -247,6 +247,8 @@ DefaultsData* getConfigDefaults()
#if defined(WIN32) || defined(__APPLE__)
AddDEF(configData, "centerwindow", true);
#endif
+ AddDEF(configData, "audioFrequency", 22010);
+ AddDEF(configData, "audioChannels", 2);
return configData;
}
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 69ca4e759..c5efa63ad 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -31,7 +31,6 @@
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/setupitem.h"
#include "utils/gettext.h"
@@ -80,6 +79,18 @@ Setup_Audio::Setup_Audio()
new SetupItemSlider(_("Music volume"), "", "musicVolume",
this, "musicVolumeEvent", 0, sound.getMaxVolume(), 150, true);
+ new SetupItemIntTextField(_("Audio frequency"), "",
+ "audioFrequency", this, "audioFrequencyEvent", 14000, 192000);
+
+ mChannelsList = new SetupItemNames();
+ mChannelsList->push_back(_("mono"));
+ mChannelsList->push_back(_("stereo"));
+ mChannelsList->push_back(_("surround"));
+ mChannelsList->push_back(_("surround+center+lfe"));
+ new SetupItemSlider2(_("Audio channels"), "", "audioChannels", this,
+ "audioChannels", 1, 4, mChannelsList);
+
+
new SetupItemLabel(_("Sound effects"), "", this);
new SetupItemSound(_("Information dialog sound"), "",
@@ -121,6 +132,9 @@ Setup_Audio::~Setup_Audio()
{
delete mSoundModel;
mSoundModel = nullptr;
+
+ delete mChannelsList;
+ mChannelsList = nullptr;
}
void Setup_Audio::apply()
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index 21b661bcb..e79beaab0 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -25,6 +25,7 @@
#include "guichanfwd.h"
+#include "gui/widgets/setupitem.h"
#include "gui/widgets/setuptabscroll.h"
#include <guichan/actionlistener.hpp>
@@ -40,6 +41,8 @@ class Setup_Audio : public SetupTabScroll
private:
gcn::ListModel *mSoundModel;
+
+ SetupItemNames *mChannelsList;
};
#endif
diff --git a/src/sound.cpp b/src/sound.cpp
index 5b7f1201d..bc3953127 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -110,9 +110,22 @@ void Sound::init()
}
const size_t audioBuffer = 4096;
+ int channels = config.getIntValue("audioChannels");
+ switch (channels)
+ {
+ case 3:
+ channels = 4;
+ break;
+ case 4:
+ channels = 6;
+ break;
+ default:
+ break;
+ }
+
+ const int res = Mix_OpenAudio(config.getIntValue("audioFrequency"),
+ MIX_DEFAULT_FORMAT, channels, audioBuffer);
- const int res = Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT,
- MIX_DEFAULT_CHANNELS, audioBuffer);
if (res < 0)
{
logger->log("Sound::init Could not initialize audio: %s",