| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 // restarts after crashing. | 585 // restarts after crashing. |
| 586 LogErrors(); | 586 LogErrors(); |
| 587 InitializeAudioState(); | 587 InitializeAudioState(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void CrasAudioHandler::NodesChanged() { | 590 void CrasAudioHandler::NodesChanged() { |
| 591 if (cras_service_available_) | 591 if (cras_service_available_) |
| 592 GetNodes(); | 592 GetNodes(); |
| 593 } | 593 } |
| 594 | 594 |
| 595 void CrasAudioHandler::OutputNodeVolumeChanged(uint64_t node_id, int volume) { |
| 596 const AudioDevice* device = this->GetDeviceFromId(node_id); |
| 597 int old_volume; |
| 598 |
| 599 // If this is not an active output node, ignore this event. Because when this |
| 600 // node set to active, it will be applied with the volume value stored in |
| 601 // preference. |
| 602 if (!device || !device->active || device->is_input) |
| 603 return; |
| 604 |
| 605 // If this callback is triggered by a response to previous set volume command, |
| 606 // do nothing. |
| 607 old_volume = |
| 608 static_cast<int>(audio_pref_handler_->GetOutputVolumeValue(device)); |
| 609 if (old_volume == volume) |
| 610 return; |
| 611 |
| 612 // Otherwise another app or the hardware itself just changed volume, update |
| 613 // the new volume value to all active output nodes. |
| 614 SetOutputVolumePercent(volume); |
| 615 } |
| 616 |
| 595 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) { | 617 void CrasAudioHandler::ActiveOutputNodeChanged(uint64_t node_id) { |
| 596 if (active_output_node_id_ == node_id) | 618 if (active_output_node_id_ == node_id) |
| 597 return; | 619 return; |
| 598 | 620 |
| 599 // Active audio output device should always be changed by chrome. | 621 // Active audio output device should always be changed by chrome. |
| 600 // During system boot, cras may change active input to unknown device 0x1, | 622 // During system boot, cras may change active input to unknown device 0x1, |
| 601 // we don't need to log it, since it is not an valid device. | 623 // we don't need to log it, since it is not an valid device. |
| 602 if (GetDeviceFromId(node_id)) { | 624 if (GetDeviceFromId(node_id)) { |
| 603 LOG_IF(WARNING, log_errors_) | 625 LOG_IF(WARNING, log_errors_) |
| 604 << "Active output node changed unexpectedly by system node_id=" | 626 << "Active output node changed unexpectedly by system node_id=" |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 hdmi_rediscover_grace_period_duration_in_ms_), | 1330 hdmi_rediscover_grace_period_duration_in_ms_), |
| 1309 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); | 1331 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); |
| 1310 } | 1332 } |
| 1311 | 1333 |
| 1312 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( | 1334 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( |
| 1313 int duration_in_ms) { | 1335 int duration_in_ms) { |
| 1314 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; | 1336 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; |
| 1315 } | 1337 } |
| 1316 | 1338 |
| 1317 } // namespace chromeos | 1339 } // namespace chromeos |
| OLD | NEW |