Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(827)

Side by Side Diff: chromeos/audio/cras_audio_handler.cc

Issue 1268593002: Fix the UI issue for showing output muted in ash tray after the device wakes up with hdmi output re… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2454
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Save the mute state for all active output audio devices. 364 // Save the mute state for all active output audio devices.
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(
374 OnOutputMuteChanged(output_mute_on_)); 375 AudioObserver, observers_,
376 OnOutputMuteChanged(output_mute_on_, false /* system_adjust */));
375 } 377 }
376 378
377 void CrasAudioHandler::AdjustOutputVolumeToAudibleLevel() { 379 void CrasAudioHandler::AdjustOutputVolumeToAudibleLevel() {
378 if (output_volume_ <= kMuteThresholdPercent) { 380 if (output_volume_ <= kMuteThresholdPercent) {
379 // Avoid the situation when sound has been unmuted, but the volume 381 // 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. 382 // is set to a very low value, so user still can't hear any sound.
381 SetOutputVolumePercent(kDefaultUnmuteVolumePercent); 383 SetOutputVolumePercent(kDefaultUnmuteVolumePercent);
382 } 384 }
383 } 385 }
384 386
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 if (notify) 1009 if (notify)
1008 NotifyActiveNodeChanged(false); 1010 NotifyActiveNodeChanged(false);
1009 } 1011 }
1010 } 1012 }
1011 1013
1012 void CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod() { 1014 void CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod() {
1013 VLOG(1) << "HDMI output re-discover grace period ends."; 1015 VLOG(1) << "HDMI output re-discover grace period ends.";
1014 hdmi_rediscovering_ = false; 1016 hdmi_rediscovering_ = false;
1015 if (!IsOutputMutedForDevice(active_output_node_id_)) { 1017 if (!IsOutputMutedForDevice(active_output_node_id_)) {
1016 // Unmute the audio output after the HDMI transition period. 1018 // Unmute the audio output after the HDMI transition period.
1017 VLOG(1) << "Unmute output after HDMI rediscovring grace period."; 1019 VLOG(1) << "Unmute output after HDMI rediscovering grace period.";
1018 SetOutputMuteInternal(false); 1020 SetOutputMuteInternal(false);
1021
1022 // Notify UI about the mute state change.
1023 FOR_EACH_OBSERVER(
1024 AudioObserver, observers_,
1025 OnOutputMuteChanged(output_mute_on_, true /* system adjustment */));
1019 } 1026 }
1020 } 1027 }
1021 1028
1022 bool CrasAudioHandler::IsHDMIPrimaryOutputDevice() const { 1029 bool CrasAudioHandler::IsHDMIPrimaryOutputDevice() const {
1023 const AudioDevice* device = GetDeviceFromId(active_output_node_id_); 1030 const AudioDevice* device = GetDeviceFromId(active_output_node_id_);
1024 return (device && device->type == chromeos::AUDIO_TYPE_HDMI); 1031 return (device && device->type == chromeos::AUDIO_TYPE_HDMI);
1025 } 1032 }
1026 1033
1027 void CrasAudioHandler::StartHDMIRediscoverGracePeriod() { 1034 void CrasAudioHandler::StartHDMIRediscoverGracePeriod() {
1028 VLOG(1) << "Start HDMI rediscovering grace period."; 1035 VLOG(1) << "Start HDMI rediscovering grace period.";
1029 hdmi_rediscovering_ = true; 1036 hdmi_rediscovering_ = true;
1030 hdmi_rediscover_timer_.Stop(); 1037 hdmi_rediscover_timer_.Stop();
1031 hdmi_rediscover_timer_.Start( 1038 hdmi_rediscover_timer_.Start(
1032 FROM_HERE, base::TimeDelta::FromMilliseconds( 1039 FROM_HERE, base::TimeDelta::FromMilliseconds(
1033 hdmi_rediscover_grace_period_duration_in_ms_), 1040 hdmi_rediscover_grace_period_duration_in_ms_),
1034 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); 1041 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod);
1035 } 1042 }
1036 1043
1037 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( 1044 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting(
1038 int duration_in_ms) { 1045 int duration_in_ms) {
1039 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; 1046 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms;
1040 } 1047 }
1041 1048
1042 } // namespace chromeos 1049 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698