Chromium Code Reviews| Index: ash/common/system/chromeos/audio/volume_view.cc |
| diff --git a/ash/common/system/chromeos/audio/volume_view.cc b/ash/common/system/chromeos/audio/volume_view.cc |
| index 38d050b98627ee8bf140e19c4b6c52997c91cb1a..a52c4bbe1e25184f0f432b8c2eb872b4f50555ff 100644 |
| --- a/ash/common/system/chromeos/audio/volume_view.cc |
| +++ b/ash/common/system/chromeos/audio/volume_view.cc |
| @@ -227,6 +227,9 @@ void VolumeView::Update() { |
| } |
| void VolumeView::SetVolumeLevel(float percent) { |
| + // Update volume level to the current audio level. |
| + Update(); |
| + |
| // Slider's value is in finer granularity than audio volume level(0.01), |
| // there will be a small discrepancy between slider's value and volume level |
| // on audio side. To avoid the jittering in slider UI, do not set change |
| @@ -268,7 +271,7 @@ void VolumeView::UpdateDeviceTypeAndMore() { |
| } |
| } |
| -void VolumeView::HandleVolumeUp(float level) { |
| +void VolumeView::HandleVolumeUp(int level) { |
| audio_delegate_->SetOutputVolumeLevel(level); |
| if (audio_delegate_->IsOutputAudioMuted() && |
| level > audio_delegate_->GetOutputDefaultVolumeMuteLevel()) { |
| @@ -276,7 +279,7 @@ void VolumeView::HandleVolumeUp(float level) { |
| } |
| } |
| -void VolumeView::HandleVolumeDown(float level) { |
| +void VolumeView::HandleVolumeDown(int level) { |
| audio_delegate_->SetOutputVolumeLevel(level); |
| if (!audio_delegate_->IsOutputAudioMuted() && |
| level <= audio_delegate_->GetOutputDefaultVolumeMuteLevel()) { |
| @@ -306,11 +309,9 @@ void VolumeView::SliderValueChanged(views::Slider* sender, |
| float old_value, |
| views::SliderChangeReason reason) { |
| if (reason == views::VALUE_CHANGED_BY_USER) { |
| - float new_volume = value * 100.0f; |
| - float current_volume = audio_delegate_->GetOutputVolumeLevel(); |
| - // Do not call change audio volume if the difference is less than |
| - // 1%, which is beyond cras audio api's granularity for output volume. |
| - if (std::abs(new_volume - current_volume) < 1.0f) |
| + int new_volume = value * 100; |
|
James Cook
2016/11/11 22:30:26
an explicit static_cast<int>(value * 100) would in
|
| + int current_volume = audio_delegate_->GetOutputVolumeLevel(); |
| + if (new_volume == current_volume) |
| return; |
| WmShell::Get()->RecordUserMetricsAction( |
| is_default_view_ ? UMA_STATUS_AREA_CHANGED_VOLUME_MENU |