| 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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 bool found_active_device = false; | 1009 bool found_active_device = false; |
| 1010 bool last_active_device_activate_by_user = false; | 1010 bool last_active_device_activate_by_user = false; |
| 1011 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); | 1011 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); |
| 1012 it != audio_devices_.end(); ++it) { | 1012 it != audio_devices_.end(); ++it) { |
| 1013 AudioDevice device = it->second; | 1013 AudioDevice device = it->second; |
| 1014 if (device.is_input != is_input || !device.is_for_simple_usage()) | 1014 if (device.is_input != is_input || !device.is_for_simple_usage()) |
| 1015 continue; | 1015 continue; |
| 1016 | 1016 |
| 1017 bool active = false; | 1017 bool active = false; |
| 1018 bool activate_by_user = false; | 1018 bool activate_by_user = false; |
| 1019 // If the device entry is not found in prefs, it is likley a new audio |
| 1020 // device plugged in after the cros is powered down. We should ignore the |
| 1021 // previously saved active device, and select the active device by priority. |
| 1022 // crbug.com/622045. |
| 1019 if (!audio_pref_handler_->GetDeviceActive(device, &active, | 1023 if (!audio_pref_handler_->GetDeviceActive(device, &active, |
| 1020 &activate_by_user) || | 1024 &activate_by_user)) { |
| 1021 !active) { | 1025 return false; |
| 1026 } |
| 1027 |
| 1028 if (!active) |
| 1022 continue; | 1029 continue; |
| 1023 } | |
| 1024 | 1030 |
| 1025 if (!found_active_device) { | 1031 if (!found_active_device) { |
| 1026 found_active_device = true; | 1032 found_active_device = true; |
| 1027 *active_device = device; | 1033 *active_device = device; |
| 1028 last_active_device_activate_by_user = activate_by_user; | 1034 last_active_device_activate_by_user = activate_by_user; |
| 1029 continue; | 1035 continue; |
| 1030 } | 1036 } |
| 1031 | 1037 |
| 1032 // Choose the best one among multiple active devices from prefs. | 1038 // Choose the best one among multiple active devices from prefs. |
| 1033 if (activate_by_user) { | 1039 if (activate_by_user) { |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 hdmi_rediscover_grace_period_duration_in_ms_), | 1378 hdmi_rediscover_grace_period_duration_in_ms_), |
| 1373 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); | 1379 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); |
| 1374 } | 1380 } |
| 1375 | 1381 |
| 1376 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( | 1382 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( |
| 1377 int duration_in_ms) { | 1383 int duration_in_ms) { |
| 1378 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; | 1384 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; |
| 1379 } | 1385 } |
| 1380 | 1386 |
| 1381 } // namespace chromeos | 1387 } // namespace chromeos |
| OLD | NEW |