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

Unified Diff: chromeos/audio/cras_audio_handler.cc

Issue 2605983002: Simplify logic behind chrome.audio.setActiveDevices (Closed)
Patch Set: . Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/audio/cras_audio_handler.cc
diff --git a/chromeos/audio/cras_audio_handler.cc b/chromeos/audio/cras_audio_handler.cc
index 6f34b66fa6193225d9973d0ecbc3aaede5d8c556..a6cd9f0e30cfb0d1b64cde3c3ec24acd318642a2 100644
--- a/chromeos/audio/cras_audio_handler.cc
+++ b/chromeos/audio/cras_audio_handler.cc
@@ -268,13 +268,36 @@ void CrasAudioHandler::ChangeActiveNodes(const NodeIdList& new_active_ids) {
output_devices.push_back(*device);
}
if (!input_devices.empty())
- SetActiveNodes(input_devices, true /* is_input */);
+ SetActiveDevices(input_devices, true /* is_input */);
if (!output_devices.empty())
- SetActiveNodes(output_devices, false /* is_input */);
+ SetActiveDevices(output_devices, false /* is_input */);
}
-void CrasAudioHandler::SetActiveNodes(const AudioDeviceList& devices,
+bool CrasAudioHandler::SetActiveInputNodes(const NodeIdList& node_ids) {
+ return SetActiveNodes(node_ids, true /* is_input */);
+}
+
+bool CrasAudioHandler::SetActiveOutputNodes(const NodeIdList& node_ids) {
+ return SetActiveNodes(node_ids, false /* is_input */);
+}
+
+bool CrasAudioHandler::SetActiveNodes(const NodeIdList& node_ids,
bool is_input) {
+ chromeos::AudioDeviceList devices;
+ for (uint64_t id : node_ids) {
+ const chromeos::AudioDevice* device = GetDeviceFromId(id);
+ if (!device || device->is_input != is_input)
+ return false;
+
+ devices.push_back(*device);
+ }
+
+ SetActiveDevices(devices, is_input);
+ return true;
+}
+
+void CrasAudioHandler::SetActiveDevices(const AudioDeviceList& devices,
+ bool is_input) {
std::set<uint64_t> new_active_ids;
for (const auto& active_device : devices) {
CHECK_EQ(is_input, active_device.is_input);
« no previous file with comments | « chromeos/audio/cras_audio_handler.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698