| 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 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 else | 824 else |
| 825 output_devices_pq_.push(device); | 825 output_devices_pq_.push(device); |
| 826 } | 826 } |
| 827 | 827 |
| 828 // If audio nodes change is caused by unplugging some non-active audio | 828 // If audio nodes change is caused by unplugging some non-active audio |
| 829 // devices, the previously set active audio device will stay active. | 829 // devices, the previously set active audio device will stay active. |
| 830 // Otherwise, switch to a new active audio device according to their priority. | 830 // Otherwise, switch to a new active audio device according to their priority. |
| 831 if (input_devices_changed && | 831 if (input_devices_changed && |
| 832 !NonActiveDeviceUnplugged(old_audio_devices_size, | 832 !NonActiveDeviceUnplugged(old_audio_devices_size, |
| 833 audio_devices_.size(), | 833 audio_devices_.size(), |
| 834 active_input_node_id_) && | 834 active_input_node_id_)) { |
| 835 !input_devices_pq_.empty()) | 835 // Some devices like chromeboxes don't have the internal audio input. In |
| 836 SwitchToDevice(input_devices_pq_.top(), true); | 836 // that case the active input node id should be reset. |
| 837 if (input_devices_pq_.empty()) { |
| 838 active_input_node_id_ = 0; |
| 839 NotifyActiveNodeChanged(true); |
| 840 } else { |
| 841 SwitchToDevice(input_devices_pq_.top(), true); |
| 842 } |
| 843 } |
| 837 if (output_devices_changed && | 844 if (output_devices_changed && |
| 838 !NonActiveDeviceUnplugged(old_audio_devices_size, | 845 !NonActiveDeviceUnplugged(old_audio_devices_size, |
| 839 audio_devices_.size(), | 846 audio_devices_.size(), |
| 840 active_output_node_id_) && | 847 active_output_node_id_)) { |
| 841 !output_devices_pq_.empty()) { | 848 // This is really unlikely to happen because all ChromeOS devices have the |
| 842 SwitchToDevice(output_devices_pq_.top(), true); | 849 // internal audio output. |
| 850 if (output_devices_pq_.empty()) { |
| 851 active_output_node_id_ = 0; |
| 852 NotifyActiveNodeChanged(false); |
| 853 } else { |
| 854 SwitchToDevice(output_devices_pq_.top(), true); |
| 855 } |
| 843 } | 856 } |
| 844 } | 857 } |
| 845 | 858 |
| 846 void CrasAudioHandler::HandleGetNodes(const chromeos::AudioNodeList& node_list, | 859 void CrasAudioHandler::HandleGetNodes(const chromeos::AudioNodeList& node_list, |
| 847 bool success) { | 860 bool success) { |
| 848 if (!success) { | 861 if (!success) { |
| 849 LOG_IF(ERROR, log_errors_) << "Failed to retrieve audio nodes data"; | 862 LOG_IF(ERROR, log_errors_) << "Failed to retrieve audio nodes data"; |
| 850 return; | 863 return; |
| 851 } | 864 } |
| 852 | 865 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 active_output_node_id_ = 0; | 923 active_output_node_id_ = 0; |
| 911 chromeos::DBusThreadManager::Get() | 924 chromeos::DBusThreadManager::Get() |
| 912 ->GetCrasAudioClient() | 925 ->GetCrasAudioClient() |
| 913 ->RemoveActiveOutputNode(node_id); | 926 ->RemoveActiveOutputNode(node_id); |
| 914 if (notify) | 927 if (notify) |
| 915 NotifyActiveNodeChanged(false); | 928 NotifyActiveNodeChanged(false); |
| 916 } | 929 } |
| 917 } | 930 } |
| 918 | 931 |
| 919 } // namespace chromeos | 932 } // namespace chromeos |
| OLD | NEW |