diff options
| author | skidau <skidau@gmail.com> | 2015-01-08 14:09:18 +1100 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2015-01-08 14:09:18 +1100 |
| commit | 25c6f6e6a1603b833954461a10966edeaf58eae8 (patch) | |
| tree | 180be061528dd268e210859461971ce9f7996b13 /Source/Core/AudioCommon/AudioCommon.cpp | |
| parent | 660e0476c76967cdb82d8cbfac4ee99973b490df (diff) | |
| parent | 5de43536ba874b0cee8ce091ed63050b9699917d (diff) | |
Merge pull request #1782 from FL-dolphinemu/master
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(); + } } |
