Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chromeos/audio/cras_audio_handler.h" | 5 #include "chromeos/audio/cras_audio_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 void CrasAudioHandler::AudioObserver::OnOutputNodeVolumeChanged( | 62 void CrasAudioHandler::AudioObserver::OnOutputNodeVolumeChanged( |
| 63 uint64_t /* node_id */, | 63 uint64_t /* node_id */, |
| 64 int /* volume */) { | 64 int /* volume */) { |
| 65 } | 65 } |
| 66 | 66 |
| 67 void CrasAudioHandler::AudioObserver::OnInputNodeGainChanged( | 67 void CrasAudioHandler::AudioObserver::OnInputNodeGainChanged( |
| 68 uint64_t /* node_id */, | 68 uint64_t /* node_id */, |
| 69 int /* gain */) { | 69 int /* gain */) { |
| 70 } | 70 } |
| 71 | 71 |
| 72 void CrasAudioHandler::AudioObserver::OnOutputMuteChanged(bool /* mute_on */) { | 72 void CrasAudioHandler::AudioObserver::OnOutputMuteChanged( |
| 73 } | 73 bool /* mute_on */, |
| 74 bool /* system_adjust */) {} | |
| 74 | 75 |
| 75 void CrasAudioHandler::AudioObserver::OnInputMuteChanged(bool /* mute_on */) { | 76 void CrasAudioHandler::AudioObserver::OnInputMuteChanged(bool /* mute_on */) { |
| 76 } | 77 } |
| 77 | 78 |
| 78 void CrasAudioHandler::AudioObserver::OnAudioNodesChanged() { | 79 void CrasAudioHandler::AudioObserver::OnAudioNodesChanged() { |
| 79 } | 80 } |
| 80 | 81 |
| 81 void CrasAudioHandler::AudioObserver::OnActiveOutputNodeChanged() { | 82 void CrasAudioHandler::AudioObserver::OnActiveOutputNodeChanged() { |
| 82 } | 83 } |
| 83 | 84 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); | 365 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); |
| 365 it != audio_devices_.end(); | 366 it != audio_devices_.end(); |
| 366 it++) { | 367 it++) { |
| 367 const AudioDevice& device = it->second; | 368 const AudioDevice& device = it->second; |
| 368 if (!device.is_input && device.active) { | 369 if (!device.is_input && device.active) { |
| 369 audio_pref_handler_->SetMuteValue(device, output_mute_on_); | 370 audio_pref_handler_->SetMuteValue(device, output_mute_on_); |
| 370 } | 371 } |
| 371 } | 372 } |
| 372 | 373 |
| 373 FOR_EACH_OBSERVER(AudioObserver, observers_, | 374 FOR_EACH_OBSERVER(AudioObserver, observers_, |
| 374 OnOutputMuteChanged(output_mute_on_)); | 375 OnOutputMuteChanged(output_mute_on_, false)); |
|
stevenjb
2015/07/28 21:36:52
false /* system_adjust */
jennyz
2015/07/28 22:40:44
Done.
| |
| 375 } | 376 } |
| 376 | 377 |
| 377 void CrasAudioHandler::AdjustOutputVolumeToAudibleLevel() { | 378 void CrasAudioHandler::AdjustOutputVolumeToAudibleLevel() { |
| 378 if (output_volume_ <= kMuteThresholdPercent) { | 379 if (output_volume_ <= kMuteThresholdPercent) { |
| 379 // Avoid the situation when sound has been unmuted, but the volume | 380 // Avoid the situation when sound has been unmuted, but the volume |
| 380 // is set to a very low value, so user still can't hear any sound. | 381 // is set to a very low value, so user still can't hear any sound. |
| 381 SetOutputVolumePercent(kDefaultUnmuteVolumePercent); | 382 SetOutputVolumePercent(kDefaultUnmuteVolumePercent); |
| 382 } | 383 } |
| 383 } | 384 } |
| 384 | 385 |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 if (notify) | 1008 if (notify) |
| 1008 NotifyActiveNodeChanged(false); | 1009 NotifyActiveNodeChanged(false); |
| 1009 } | 1010 } |
| 1010 } | 1011 } |
| 1011 | 1012 |
| 1012 void CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod() { | 1013 void CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod() { |
| 1013 VLOG(1) << "HDMI output re-discover grace period ends."; | 1014 VLOG(1) << "HDMI output re-discover grace period ends."; |
| 1014 hdmi_rediscovering_ = false; | 1015 hdmi_rediscovering_ = false; |
| 1015 if (!IsOutputMutedForDevice(active_output_node_id_)) { | 1016 if (!IsOutputMutedForDevice(active_output_node_id_)) { |
| 1016 // Unmute the audio output after the HDMI transition period. | 1017 // Unmute the audio output after the HDMI transition period. |
| 1017 VLOG(1) << "Unmute output after HDMI rediscovring grace period."; | 1018 VLOG(1) << "Unmute output after HDMI rediscovering grace period."; |
| 1018 SetOutputMuteInternal(false); | 1019 SetOutputMuteInternal(false); |
| 1020 | |
| 1021 // Notify UI about the mute state change. | |
| 1022 FOR_EACH_OBSERVER( | |
| 1023 AudioObserver, observers_, | |
| 1024 OnOutputMuteChanged(output_mute_on_, true)); /* system adjustment */ | |
|
stevenjb
2015/07/28 21:36:52
nit: 'true /* system_adjust */' (or put true on a
jennyz
2015/07/28 22:40:44
Done.
| |
| 1019 } | 1025 } |
| 1020 } | 1026 } |
| 1021 | 1027 |
| 1022 bool CrasAudioHandler::IsHDMIPrimaryOutputDevice() const { | 1028 bool CrasAudioHandler::IsHDMIPrimaryOutputDevice() const { |
| 1023 const AudioDevice* device = GetDeviceFromId(active_output_node_id_); | 1029 const AudioDevice* device = GetDeviceFromId(active_output_node_id_); |
| 1024 return (device && device->type == chromeos::AUDIO_TYPE_HDMI); | 1030 return (device && device->type == chromeos::AUDIO_TYPE_HDMI); |
| 1025 } | 1031 } |
| 1026 | 1032 |
| 1027 void CrasAudioHandler::StartHDMIRediscoverGracePeriod() { | 1033 void CrasAudioHandler::StartHDMIRediscoverGracePeriod() { |
| 1028 VLOG(1) << "Start HDMI rediscovering grace period."; | 1034 VLOG(1) << "Start HDMI rediscovering grace period."; |
| 1029 hdmi_rediscovering_ = true; | 1035 hdmi_rediscovering_ = true; |
| 1030 hdmi_rediscover_timer_.Stop(); | 1036 hdmi_rediscover_timer_.Stop(); |
| 1031 hdmi_rediscover_timer_.Start( | 1037 hdmi_rediscover_timer_.Start( |
| 1032 FROM_HERE, base::TimeDelta::FromMilliseconds( | 1038 FROM_HERE, base::TimeDelta::FromMilliseconds( |
| 1033 hdmi_rediscover_grace_period_duration_in_ms_), | 1039 hdmi_rediscover_grace_period_duration_in_ms_), |
| 1034 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); | 1040 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); |
| 1035 } | 1041 } |
| 1036 | 1042 |
| 1037 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( | 1043 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( |
| 1038 int duration_in_ms) { | 1044 int duration_in_ms) { |
| 1039 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; | 1045 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; |
| 1040 } | 1046 } |
| 1041 | 1047 |
| 1042 } // namespace chromeos | 1048 } // namespace chromeos |
| OLD | NEW |