Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: chromeos/audio/cras_audio_handler.cc

Issue 2270693005: Fix the corner case for new audio device is not selected as active if it is plugged in for the firs… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 bool found_active_device = false; 1008 bool found_active_device = false;
1009 bool last_active_device_activate_by_user = false; 1009 bool last_active_device_activate_by_user = false;
1010 for (AudioDeviceMap::const_iterator it = audio_devices_.begin(); 1010 for (AudioDeviceMap::const_iterator it = audio_devices_.begin();
1011 it != audio_devices_.end(); ++it) { 1011 it != audio_devices_.end(); ++it) {
1012 AudioDevice device = it->second; 1012 AudioDevice device = it->second;
1013 if (device.is_input != is_input || !device.is_for_simple_usage()) 1013 if (device.is_input != is_input || !device.is_for_simple_usage())
1014 continue; 1014 continue;
1015 1015
1016 bool active = false; 1016 bool active = false;
1017 bool activate_by_user = false; 1017 bool activate_by_user = false;
1018 // If the device entry is not found in prefs, it is likley a new audio
1019 // device plugged in after the cros is powered down. We should ignore the
1020 // previously saved active device, and select the active device by priority.
1021 // crbug.com/622045.
1018 if (!audio_pref_handler_->GetDeviceActive(device, &active, 1022 if (!audio_pref_handler_->GetDeviceActive(device, &active,
1019 &activate_by_user) || 1023 &activate_by_user)) {
1020 !active) { 1024 return false;
1025 }
1026
1027 if (!active)
1021 continue; 1028 continue;
1022 }
1023 1029
1024 if (!found_active_device) { 1030 if (!found_active_device) {
1025 found_active_device = true; 1031 found_active_device = true;
1026 *active_device = device; 1032 *active_device = device;
1027 last_active_device_activate_by_user = activate_by_user; 1033 last_active_device_activate_by_user = activate_by_user;
1028 continue; 1034 continue;
1029 } 1035 }
1030 1036
1031 // Choose the best one among multiple active devices from prefs. 1037 // Choose the best one among multiple active devices from prefs.
1032 if (activate_by_user) { 1038 if (activate_by_user) {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 hdmi_rediscover_grace_period_duration_in_ms_), 1365 hdmi_rediscover_grace_period_duration_in_ms_),
1360 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod); 1366 this, &CrasAudioHandler::UpdateAudioAfterHDMIRediscoverGracePeriod);
1361 } 1367 }
1362 1368
1363 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting( 1369 void CrasAudioHandler::SetHDMIRediscoverGracePeriodForTesting(
1364 int duration_in_ms) { 1370 int duration_in_ms) {
1365 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms; 1371 hdmi_rediscover_grace_period_duration_in_ms_ = duration_in_ms;
1366 } 1372 }
1367 1373
1368 } // namespace chromeos 1374 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/audio/audio_devices_pref_handler_impl_unittest.cc ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698