Chromium Code Reviews| 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/audio_device.h" | 5 #include "chromeos/audio/audio_device.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 case AUDIO_TYPE_KEYBOARD_MIC: | 30 case AUDIO_TYPE_KEYBOARD_MIC: |
| 31 case AUDIO_TYPE_AOKR: | 31 case AUDIO_TYPE_AOKR: |
| 32 case AUDIO_TYPE_POST_MIX_LOOPBACK: | 32 case AUDIO_TYPE_POST_MIX_LOOPBACK: |
| 33 case AUDIO_TYPE_POST_DSP_LOOPBACK: | 33 case AUDIO_TYPE_POST_DSP_LOOPBACK: |
| 34 case AUDIO_TYPE_OTHER: | 34 case AUDIO_TYPE_OTHER: |
| 35 default: | 35 default: |
| 36 return 0; | 36 return 0; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Check if a node type is for simple record/playback usage. | |
| 41 // Special usages like keyboard mic, AOKR, loopback are excluded. | |
| 42 bool IsForSimpleUsage(AudioDeviceType type) { | |
| 43 return (type == AUDIO_TYPE_HEADPHONE || type == AUDIO_TYPE_INTERNAL_MIC || | |
|
jennyz
2015/06/16 21:51:35
nit: How about put each type is a separate line, s
cychiang
2015/06/23 06:05:40
Done.
| |
| 44 type == AUDIO_TYPE_MIC || type == AUDIO_TYPE_USB || | |
| 45 type == AUDIO_TYPE_BLUETOOTH || type == AUDIO_TYPE_HDMI || | |
| 46 type == AUDIO_TYPE_INTERNAL_SPEAKER); | |
| 47 } | |
| 48 | |
| 40 } // namespace | 49 } // namespace |
| 41 | 50 |
| 42 // static | 51 // static |
| 43 std::string AudioDevice::GetTypeString(AudioDeviceType type) { | 52 std::string AudioDevice::GetTypeString(AudioDeviceType type) { |
| 44 switch (type) { | 53 switch (type) { |
| 45 case AUDIO_TYPE_HEADPHONE: | 54 case AUDIO_TYPE_HEADPHONE: |
| 46 return "HEADPHONE"; | 55 return "HEADPHONE"; |
| 47 case AUDIO_TYPE_MIC: | 56 case AUDIO_TYPE_MIC: |
| 48 return "MIC"; | 57 return "MIC"; |
| 49 case AUDIO_TYPE_USB: | 58 case AUDIO_TYPE_USB: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 else if (node_type.find("POST_MIX_LOOPBACK") != std::string::npos) | 103 else if (node_type.find("POST_MIX_LOOPBACK") != std::string::npos) |
| 95 return AUDIO_TYPE_POST_MIX_LOOPBACK; | 104 return AUDIO_TYPE_POST_MIX_LOOPBACK; |
| 96 else if (node_type.find("POST_DSP_LOOPBACK") != std::string::npos) | 105 else if (node_type.find("POST_DSP_LOOPBACK") != std::string::npos) |
| 97 return AUDIO_TYPE_POST_DSP_LOOPBACK; | 106 return AUDIO_TYPE_POST_DSP_LOOPBACK; |
| 98 else | 107 else |
| 99 return AUDIO_TYPE_OTHER; | 108 return AUDIO_TYPE_OTHER; |
| 100 } | 109 } |
| 101 | 110 |
| 102 AudioDevice::AudioDevice() | 111 AudioDevice::AudioDevice() |
| 103 : is_input(false), | 112 : is_input(false), |
| 113 is_for_simple_usage(true), | |
| 104 id(0), | 114 id(0), |
| 105 display_name(""), | 115 display_name(""), |
| 106 type(AUDIO_TYPE_OTHER), | 116 type(AUDIO_TYPE_OTHER), |
|
jennyz
2015/06/16 21:51:35
This seems conflicting with IsForSimpleUsage(), th
cychiang
2015/06/23 06:05:40
Done.
| |
| 107 priority(0), | 117 priority(0), |
| 108 active(false), | 118 active(false), |
| 109 plugged_time(0) { | 119 plugged_time(0) { |
| 110 } | 120 } |
| 111 | 121 |
| 112 AudioDevice::AudioDevice(const AudioNode& node) { | 122 AudioDevice::AudioDevice(const AudioNode& node) { |
| 113 is_input = node.is_input; | 123 is_input = node.is_input; |
| 114 id = node.id; | 124 id = node.id; |
| 115 type = GetAudioType(node.type); | 125 type = GetAudioType(node.type); |
| 126 is_for_simple_usage = IsForSimpleUsage(type); | |
|
Daniel Erat
2015/06/18 14:53:20
this member is just derived from another member, t
cychiang
2015/06/23 06:05:40
Done.
| |
| 116 if (!node.name.empty() && node.name != "(default)") | 127 if (!node.name.empty() && node.name != "(default)") |
| 117 display_name = node.name; | 128 display_name = node.name; |
| 118 else | 129 else |
| 119 display_name = node.device_name; | 130 display_name = node.device_name; |
| 120 device_name = node.device_name; | 131 device_name = node.device_name; |
| 121 priority = GetDevicePriority(type); | 132 priority = GetDevicePriority(type); |
| 122 active = node.active; | 133 active = node.active; |
| 123 plugged_time = node.plugged_time; | 134 plugged_time = node.plugged_time; |
| 124 } | 135 } |
| 125 | 136 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 144 "active = %s ", | 155 "active = %s ", |
| 145 active ? "true" : "false"); | 156 active ? "true" : "false"); |
| 146 base::StringAppendF(&result, | 157 base::StringAppendF(&result, |
| 147 "plugged_time= %s ", | 158 "plugged_time= %s ", |
| 148 base::Uint64ToString(plugged_time).c_str()); | 159 base::Uint64ToString(plugged_time).c_str()); |
| 149 | 160 |
| 150 return result; | 161 return result; |
| 151 } | 162 } |
| 152 | 163 |
| 153 } // namespace chromeos | 164 } // namespace chromeos |
| OLD | NEW |