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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 // restarts after crashing. | 555 // restarts after crashing. |
| 556 LogErrors(); | 556 LogErrors(); |
| 557 InitializeAudioState(); | 557 InitializeAudioState(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void CrasAudioHandler::NodesChanged() { | 560 void CrasAudioHandler::NodesChanged() { |
| 561 if (cras_service_available_) | 561 if (cras_service_available_) |
| 562 GetNodes(); | 562 GetNodes(); |
| 563 } | 563 } |
| 564 | 564 |
| 565 void CrasAudioHandler::OutputNodeVolumeChanged(uint64_t node_id, int volume) { | |
| 566 const AudioDevice* device = this->GetDeviceFromId(node_id); | |
| 567 int old_volume; | |
| 568 | |
| 569 if (!device || device->is_input) | |
| 570 return; | |
| 571 | |
| 572 // If this callback is triggered by a response to previous set volume command, | |
| 573 // do nothing. | |
| 574 old_volume = | |
| 575 static_cast<int>(audio_pref_handler_->GetOutputVolumeValue(device)); | |
| 576 if (old_volume == volume) | |
| 577 return; | |
| 578 | |
| 579 // Otherwise another app or the hardware itself just changed volume, update | |
| 580 // the new volume value. | |
| 581 SetOutputNodeVolumePercent(node_id, volume); | |
|
jennyz
2016/05/06 18:11:08
This will have a glitch for the multiple active no
hychao
2016/05/12 08:06:27
Done.
| |
| 582 } | |
| 583 | |
| 565 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) { | 584 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) { |
| 566 if (active_output_node_id_ == node_id) | 585 if (active_output_node_id_ == node_id) |
| 567 return; | 586 return; |
| 568 | 587 |
| 569 // Active audio output device should always be changed by chrome. | 588 // Active audio output device should always be changed by chrome. |
| 570 // During system boot, cras may change active input to unknown device 0x1, | 589 // During system boot, cras may change active input to unknown device 0x1, |
| 571 // we don't need to log it, since it is not an valid device. | 590 // we don't need to log it, since it is not an valid device. |
| 572 if (GetDeviceFromId(node_id)) { | 591 if (GetDeviceFromId(node_id)) { |
| 573 LOG_IF(WARNING, log_errors_) | 592 LOG_IF(WARNING, log_errors_) |
| 574 << "Active output node changed unexpectedly by system node_id=" | 593 << "Active output node changed unexpectedly by system node_id=" |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1278 hdmi_rediscover_grace_period_duration_in_ms_), | 1297 hdmi_rediscover_grace_period_duration_in_ms_), |
| 1279 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); | 1298 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); |
| 1280 } | 1299 } |
| 1281 | 1300 |
| 1282 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( | 1301 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( |
| 1283 int duration_in_ms) { | 1302 int duration_in_ms) { |
| 1284 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; | 1303 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; |
| 1285 } | 1304 } |
| 1286 | 1305 |
| 1287 } // namespace chromeos | 1306 } // namespace chromeos |
| OLD | NEW |