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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 if (device.is_input) { | 845 if (device.is_input) { |
846 input_devices_pq_.push(device); | 846 input_devices_pq_.push(device); |
847 ++new_input_device_size; | 847 ++new_input_device_size; |
848 } else { | 848 } else { |
849 output_devices_pq_.push(device); | 849 output_devices_pq_.push(device); |
850 ++new_output_device_size; | 850 ++new_output_device_size; |
851 } | 851 } |
852 } | 852 } |
853 | 853 |
854 // If the previous active device is removed from the new node list, | 854 // If the previous active device is removed from the new node list, |
855 // reset active_output_node_id_. | 855 // or changed to inactive by cras, reset active_output_node_id_. |
856 if (!GetDeviceFromId(active_output_node_id_)) | 856 // See crbug.com/478968. |
| 857 const AudioDevice* active_output = GetDeviceFromId(active_output_node_id_); |
| 858 if (!active_output || !active_output->active) |
857 active_output_node_id_ = 0; | 859 active_output_node_id_ = 0; |
858 if (!GetDeviceFromId(active_input_node_id_)) | 860 const AudioDevice* active_input = GetDeviceFromId(active_input_node_id_); |
| 861 if (!active_input || !active_input->active) |
859 active_input_node_id_ = 0; | 862 active_input_node_id_ = 0; |
860 | 863 |
861 // If audio nodes change is caused by unplugging some non-active audio | 864 // If audio nodes change is caused by unplugging some non-active audio |
862 // devices, the previously set active audio device will stay active. | 865 // devices, the previously set active audio device will stay active. |
863 // Otherwise, switch to a new active audio device according to their priority. | 866 // Otherwise, switch to a new active audio device according to their priority. |
864 if (input_devices_changed && | 867 if (input_devices_changed && |
865 !NonActiveDeviceUnplugged(old_input_device_size, | 868 !NonActiveDeviceUnplugged(old_input_device_size, |
866 new_input_device_size, | 869 new_input_device_size, |
867 active_input_node_id_)) { | 870 active_input_node_id_)) { |
868 // Some devices like chromeboxes don't have the internal audio input. In | 871 // Some devices like chromeboxes don't have the internal audio input. In |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 active_output_node_id_ = 0; | 970 active_output_node_id_ = 0; |
968 chromeos::DBusThreadManager::Get() | 971 chromeos::DBusThreadManager::Get() |
969 ->GetCrasAudioClient() | 972 ->GetCrasAudioClient() |
970 ->RemoveActiveOutputNode(node_id); | 973 ->RemoveActiveOutputNode(node_id); |
971 if (notify) | 974 if (notify) |
972 NotifyActiveNodeChanged(false); | 975 NotifyActiveNodeChanged(false); |
973 } | 976 } |
974 } | 977 } |
975 | 978 |
976 } // namespace chromeos | 979 } // namespace chromeos |
OLD | NEW |