add read only option "sample_rate". Let default value to 22050

This commit is contained in:
Serge Martin 2006-10-26 10:22:11 +00:00
parent f6bdd08e3f
commit 14d320b82e
3 changed files with 8 additions and 1 deletions

View File

@ -176,6 +176,11 @@ void set_language(const std::string& s)
prefs["locale"] = s;
}
unsigned int sample_rate()
{
return lexical_cast_default<unsigned int>(prefs["sample_rate"], 22050);
}
int music_volume()
{
return lexical_cast_default<int>(prefs["music_volume"], 100);

View File

@ -64,6 +64,8 @@ namespace preferences {
bool sound_on();
bool set_sound(bool ison);
unsigned int sample_rate();
int sound_volume();
void set_sound_volume(int vol);

View File

@ -210,7 +210,7 @@ bool init_sound() {
return false;
if(!mix_ok) {
if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY,MIX_DEFAULT_FORMAT,2,buf_size) == -1) {
if(Mix_OpenAudio(preferences::sample_rate(), MIX_DEFAULT_FORMAT, 2, buf_size) == -1) {
mix_ok = false;
ERR_AUDIO << "Could not initialize audio: " << Mix_GetError() << "\n";
return false;