| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/audio/audio_handler.h" | 5 #include "chrome/browser/chromeos/audio/audio_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 local_state->ClearPref(prefs::kAudioVolumeDb); | 79 local_state->ClearPref(prefs::kAudioVolumeDb); |
| 80 local_state->UnregisterPreference(prefs::kAudioVolumeDb); | 80 local_state->UnregisterPreference(prefs::kAudioVolumeDb); |
| 81 } | 81 } |
| 82 | 82 |
| 83 double AudioHandler::GetVolumePercent() { | 83 double AudioHandler::GetVolumePercent() { |
| 84 return mixer_->GetVolumePercent(); | 84 return mixer_->GetVolumePercent(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void AudioHandler::SetVolumePercent(double volume_percent) { | 87 void AudioHandler::SetVolumePercent(double volume_percent) { |
| 88 volume_percent = min(max(volume_percent, 0.0), 100.0); | 88 volume_percent = min(max(volume_percent, 0.0), 100.0); |
| 89 if (IsMuted() && volume_percent > 0.0) |
| 90 SetMuted(false); |
| 89 mixer_->SetVolumePercent(volume_percent); | 91 mixer_->SetVolumePercent(volume_percent); |
| 90 prefs_->SetDouble(prefs::kAudioVolumePercent, volume_percent); | 92 prefs_->SetDouble(prefs::kAudioVolumePercent, volume_percent); |
| 91 FOR_EACH_OBSERVER(VolumeObserver, volume_observers_, OnVolumeChanged()); | 93 FOR_EACH_OBSERVER(VolumeObserver, volume_observers_, OnVolumeChanged()); |
| 92 } | 94 } |
| 93 | 95 |
| 94 void AudioHandler::AdjustVolumeByPercent(double adjust_by_percent) { | 96 void AudioHandler::AdjustVolumeByPercent(double adjust_by_percent) { |
| 95 SetVolumePercent(mixer_->GetVolumePercent() + adjust_by_percent); | 97 SetVolumePercent(mixer_->GetVolumePercent() + adjust_by_percent); |
| 96 } | 98 } |
| 97 | 99 |
| 98 bool AudioHandler::IsMuted() { | 100 bool AudioHandler::IsMuted() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 123 mixer_->SetVolumePercent(prefs_->GetDouble(prefs::kAudioVolumePercent)); | 125 mixer_->SetVolumePercent(prefs_->GetDouble(prefs::kAudioVolumePercent)); |
| 124 mixer_->SetMuted(prefs_->GetInteger(prefs::kAudioMute) == kPrefMuteOn); | 126 mixer_->SetMuted(prefs_->GetInteger(prefs::kAudioMute) == kPrefMuteOn); |
| 125 mixer_->Init(); | 127 mixer_->Init(); |
| 126 } | 128 } |
| 127 | 129 |
| 128 AudioHandler::~AudioHandler() { | 130 AudioHandler::~AudioHandler() { |
| 129 mixer_.reset(); | 131 mixer_.reset(); |
| 130 }; | 132 }; |
| 131 | 133 |
| 132 } // namespace chromeos | 134 } // namespace chromeos |
| OLD | NEW |