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..67577d775facca1c85d5a29363153822aeb70889 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,11 @@ 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(); |
| + int new_volume = value * 100; |
|
James Cook
2016/11/11 22:21:15
Aside: I'm a little surprised that this doesn't ge
yiyix
2016/11/11 22:27:54
Do you think adding a comment here would help the
|
| + int 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) |
| + if (std::abs(new_volume - current_volume) < 1) |
|
tdanderson
2016/11/11 19:48:35
if both values are now ints, the only way this can
yiyix
2016/11/11 22:27:54
You are right. Done
|
| return; |
| WmShell::Get()->RecordUserMetricsAction( |
| is_default_view_ ? UMA_STATUS_AREA_CHANGED_VOLUME_MENU |