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

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

Issue 515573003: app_shell: Do simple audio initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wrap line Created 6 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
« no previous file with comments | « chromeos/audio/audio_device.h ('k') | 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/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"
11 11
12 namespace chromeos {
13
12 namespace { 14 namespace {
13 15
14 // Get the priority for a particular device type. The priority returned 16 // Get the priority for a particular device type. The priority returned
15 // will be between 0 to 3, the higher number meaning a higher priority. 17 // will be between 0 to 3, the higher number meaning a higher priority.
16 uint8 GetDevicePriority(chromeos::AudioDeviceType type) { 18 uint8 GetDevicePriority(AudioDeviceType type) {
17 switch (type) { 19 switch (type) {
18 // Fall through. 20 case AUDIO_TYPE_HEADPHONE:
19 case chromeos::AUDIO_TYPE_HEADPHONE: 21 case AUDIO_TYPE_MIC:
20 case chromeos::AUDIO_TYPE_MIC: 22 case AUDIO_TYPE_USB:
21 case chromeos::AUDIO_TYPE_USB: 23 case AUDIO_TYPE_BLUETOOTH:
22 case chromeos::AUDIO_TYPE_BLUETOOTH:
23 return 3; 24 return 3;
24 case chromeos::AUDIO_TYPE_HDMI: 25 case AUDIO_TYPE_HDMI:
25 return 2; 26 return 2;
26 // Fall through. 27 case AUDIO_TYPE_INTERNAL_SPEAKER:
27 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: 28 case AUDIO_TYPE_INTERNAL_MIC:
28 case chromeos::AUDIO_TYPE_INTERNAL_MIC:
29 return 1; 29 return 1;
30 // Fall through. 30 case AUDIO_TYPE_KEYBOARD_MIC:
31 case chromeos::AUDIO_TYPE_KEYBOARD_MIC: 31 case AUDIO_TYPE_OTHER:
32 case chromeos::AUDIO_TYPE_OTHER:
33 default: 32 default:
34 return 0; 33 return 0;
35 } 34 }
36 } 35 }
37 36
38 std::string GetTypeString(chromeos::AudioDeviceType type) { 37 } // namespace
38
39 // static
40 std::string AudioDevice::GetTypeString(AudioDeviceType type) {
39 switch (type) { 41 switch (type) {
40 case chromeos::AUDIO_TYPE_HEADPHONE: 42 case AUDIO_TYPE_HEADPHONE:
41 return "HEADPHONE"; 43 return "HEADPHONE";
42 case chromeos::AUDIO_TYPE_MIC: 44 case AUDIO_TYPE_MIC:
43 return "MIC"; 45 return "MIC";
44 case chromeos::AUDIO_TYPE_USB: 46 case AUDIO_TYPE_USB:
45 return "USB"; 47 return "USB";
46 case chromeos::AUDIO_TYPE_BLUETOOTH: 48 case AUDIO_TYPE_BLUETOOTH:
47 return "BLUETOOTH"; 49 return "BLUETOOTH";
48 case chromeos::AUDIO_TYPE_HDMI: 50 case AUDIO_TYPE_HDMI:
49 return "HDMI"; 51 return "HDMI";
50 case chromeos::AUDIO_TYPE_INTERNAL_SPEAKER: 52 case AUDIO_TYPE_INTERNAL_SPEAKER:
51 return "INTERNAL_SPEAKER"; 53 return "INTERNAL_SPEAKER";
52 case chromeos::AUDIO_TYPE_INTERNAL_MIC: 54 case AUDIO_TYPE_INTERNAL_MIC:
53 return "INTERNAL_MIC"; 55 return "INTERNAL_MIC";
54 case chromeos::AUDIO_TYPE_KEYBOARD_MIC: 56 case AUDIO_TYPE_KEYBOARD_MIC:
55 return "KEYBOARD_MIC"; 57 return "KEYBOARD_MIC";
56 case chromeos::AUDIO_TYPE_OTHER: 58 case AUDIO_TYPE_OTHER:
57 default: 59 default:
58 return "OTHER"; 60 return "OTHER";
59 } 61 }
60 } 62 }
61 63
62 chromeos::AudioDeviceType GetAudioType(const std::string& node_type) { 64 // static
65 AudioDeviceType AudioDevice::GetAudioType(
66 const std::string& node_type) {
63 if (node_type.find("HEADPHONE") != std::string::npos) 67 if (node_type.find("HEADPHONE") != std::string::npos)
64 return chromeos::AUDIO_TYPE_HEADPHONE; 68 return AUDIO_TYPE_HEADPHONE;
65 else if (node_type.find("INTERNAL_MIC") != std::string::npos) 69 else if (node_type.find("INTERNAL_MIC") != std::string::npos)
66 return chromeos::AUDIO_TYPE_INTERNAL_MIC; 70 return AUDIO_TYPE_INTERNAL_MIC;
67 else if (node_type.find("KEYBOARD_MIC") != std::string::npos) 71 else if (node_type.find("KEYBOARD_MIC") != std::string::npos)
68 return chromeos::AUDIO_TYPE_KEYBOARD_MIC; 72 return AUDIO_TYPE_KEYBOARD_MIC;
69 else if (node_type.find("MIC") != std::string::npos) 73 else if (node_type.find("MIC") != std::string::npos)
70 return chromeos::AUDIO_TYPE_MIC; 74 return AUDIO_TYPE_MIC;
71 else if (node_type.find("USB") != std::string::npos) 75 else if (node_type.find("USB") != std::string::npos)
72 return chromeos::AUDIO_TYPE_USB; 76 return AUDIO_TYPE_USB;
73 else if (node_type.find("BLUETOOTH") != std::string::npos) 77 else if (node_type.find("BLUETOOTH") != std::string::npos)
74 return chromeos::AUDIO_TYPE_BLUETOOTH; 78 return AUDIO_TYPE_BLUETOOTH;
75 else if (node_type.find("HDMI") != std::string::npos) 79 else if (node_type.find("HDMI") != std::string::npos)
76 return chromeos::AUDIO_TYPE_HDMI; 80 return AUDIO_TYPE_HDMI;
77 else if (node_type.find("INTERNAL_SPEAKER") != std::string::npos) 81 else if (node_type.find("INTERNAL_SPEAKER") != std::string::npos)
78 return chromeos::AUDIO_TYPE_INTERNAL_SPEAKER; 82 return AUDIO_TYPE_INTERNAL_SPEAKER;
79 else 83 else
80 return chromeos::AUDIO_TYPE_OTHER; 84 return AUDIO_TYPE_OTHER;
81 } 85 }
82 86
83 } // namespace
84
85 namespace chromeos {
86
87 AudioDevice::AudioDevice() 87 AudioDevice::AudioDevice()
88 : is_input(false), 88 : is_input(false),
89 id(0), 89 id(0),
90 display_name(""), 90 display_name(""),
91 type(AUDIO_TYPE_OTHER), 91 type(AUDIO_TYPE_OTHER),
92 priority(0), 92 priority(0),
93 active(false), 93 active(false),
94 plugged_time(0) { 94 plugged_time(0) {
95 } 95 }
96 96
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 "active = %s ", 129 "active = %s ",
130 active ? "true" : "false"); 130 active ? "true" : "false");
131 base::StringAppendF(&result, 131 base::StringAppendF(&result,
132 "plugged_time= %s ", 132 "plugged_time= %s ",
133 base::Uint64ToString(plugged_time).c_str()); 133 base::Uint64ToString(plugged_time).c_str());
134 134
135 return result; 135 return result;
136 } 136 }
137 137
138 } // namespace chromeos 138 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/audio/audio_device.h ('k') | chromeos/audio/cras_audio_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698