diff options
| author | FL.dolphinemu <FL.dolphinemu@gmail.com> | 2014-12-28 22:03:21 +0100 |
|---|---|---|
| committer | FL.dolphinemu <FL.dolphinemu@gmail.com> | 2014-12-28 22:03:21 +0100 |
| commit | 78f8bf7423b047e31cbc22a86001206906f5dc98 (patch) | |
| tree | c7086241d6af1f27674f18d8141a7dfb145a2ffa /Source/Core/AudioCommon/AudioCommon.cpp | |
| parent | 9465a877f8e896463b9f43f94016d89019d1d5d5 (diff) | |
Issue 7968: Added keybinds for increasing, decreasing, and muting audio.
Diffstat (limited to 'Source/Core/AudioCommon/AudioCommon.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/AudioCommon.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp index cfd2b9e278..5ea79319de 100644 --- a/Source/Core/AudioCommon/AudioCommon.cpp +++ b/Source/Core/AudioCommon/AudioCommon.cpp @@ -27,6 +27,9 @@ static bool s_audio_dump_start = false; namespace AudioCommon { + static const int AUDIO_VOLUME_MIN = 0; + static const int AUDIO_VOLUME_MAX = 100; + SoundStream* InitSoundStream() { CMixer *mixer = new CMixer(48000); @@ -140,11 +143,13 @@ namespace AudioCommon } } } + void UpdateSoundStream() { if (g_sound_stream) { - g_sound_stream->SetVolume(SConfig::GetInstance().m_Volume); + int volume = SConfig::GetInstance().m_IsMuted ? 0 : SConfig::GetInstance().m_Volume; + g_sound_stream->SetVolume(volume); } } @@ -191,4 +196,31 @@ namespace AudioCommon g_sound_stream->GetMixer()->StopLogDSPAudio(); s_audio_dump_start = false; } + + void IncreaseVolume(unsigned short offset) + { + SConfig::GetInstance().m_IsMuted = false; + int& currentVolume = SConfig::GetInstance().m_Volume; + currentVolume += offset; + if (currentVolume > AUDIO_VOLUME_MAX) + currentVolume = AUDIO_VOLUME_MAX; + UpdateSoundStream(); + } + + void DecreaseVolume(unsigned short offset) + { + SConfig::GetInstance().m_IsMuted = false; + int& currentVolume = SConfig::GetInstance().m_Volume; + currentVolume -= offset; + if (currentVolume < AUDIO_VOLUME_MIN) + currentVolume = AUDIO_VOLUME_MIN; + UpdateSoundStream(); + } + + void ToggleMuteVolume() + { + bool& isMuted = SConfig::GetInstance().m_IsMuted; + isMuted = !isMuted; + UpdateSoundStream(); + } } |
