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

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

Issue 1109793005: Fix the issue where the active output device is lost after the device suspend/resume without any ac… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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
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
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
OLDNEW
« no previous file with comments | « no previous file | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698