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

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

Issue 1186293003: Implement HasInputDevices in CrasAudioManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } else { 896 } else {
897 // ditto input node case. 897 // ditto input node case.
898 if (!active_output_node_id_ || hotplug_output_nodes.empty() || 898 if (!active_output_node_id_ || hotplug_output_nodes.empty() ||
899 IsNodeInTheList(output_devices_pq_.top().id, hotplug_output_nodes)) { 899 IsNodeInTheList(output_devices_pq_.top().id, hotplug_output_nodes)) {
900 SwitchToDevice(output_devices_pq_.top(), true); 900 SwitchToDevice(output_devices_pq_.top(), true);
901 } 901 }
902 } 902 }
903 } 903 }
904 } 904 }
905 905
906 void CrasAudioHandler::UpdateAudioManagerHasInputDevices() {
907 AudioDeviceList devices;
908 GetAudioDevices(&devices);
909 for (size_t i = 0; i < devices.size(); ++i) {
910 if (devices[i].is_input && devices[i].is_for_simple_usage) {
911 media::AudioManager::Get()->SetHasInputDevices(true);
912 return;
913 }
914 }
915 media::AudioManager::Get()->SetHasInputDevices(false);
916 }
917
906 void CrasAudioHandler::HandleGetNodes(const chromeos::AudioNodeList& node_list, 918 void CrasAudioHandler::HandleGetNodes(const chromeos::AudioNodeList& node_list,
907 bool success) { 919 bool success) {
908 if (!success) { 920 if (!success) {
909 LOG_IF(ERROR, log_errors_) << "Failed to retrieve audio nodes data"; 921 LOG_IF(ERROR, log_errors_) << "Failed to retrieve audio nodes data";
910 return; 922 return;
911 } 923 }
912 924
913 UpdateDevicesAndSwitchActive(node_list); 925 UpdateDevicesAndSwitchActive(node_list);
926 UpdateAudioManagerHasInputDevices();
914 FOR_EACH_OBSERVER(AudioObserver, observers_, OnAudioNodesChanged()); 927 FOR_EACH_OBSERVER(AudioObserver, observers_, OnAudioNodesChanged());
915 } 928 }
916 929
917 void CrasAudioHandler::HandleGetNodesError(const std::string& error_name, 930 void CrasAudioHandler::HandleGetNodesError(const std::string& error_name,
918 const std::string& error_msg) { 931 const std::string& error_msg) {
919 LOG_IF(ERROR, log_errors_) << "Failed to call GetNodes: " 932 LOG_IF(ERROR, log_errors_) << "Failed to call GetNodes: "
920 << error_name << ": " << error_msg; 933 << error_name << ": " << error_msg;
921 } 934 }
922 935
923 void CrasAudioHandler::AddAdditionalActiveNode(uint64_t node_id, bool notify) { 936 void CrasAudioHandler::AddAdditionalActiveNode(uint64_t node_id, bool notify) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 active_output_node_id_ = 0; 983 active_output_node_id_ = 0;
971 chromeos::DBusThreadManager::Get() 984 chromeos::DBusThreadManager::Get()
972 ->GetCrasAudioClient() 985 ->GetCrasAudioClient()
973 ->RemoveActiveOutputNode(node_id); 986 ->RemoveActiveOutputNode(node_id);
974 if (notify) 987 if (notify)
975 NotifyActiveNodeChanged(false); 988 NotifyActiveNodeChanged(false);
976 } 989 }
977 } 990 }
978 991
979 } // namespace chromeos 992 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698