| 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 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 5 #ifndef CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| 6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 6 #define CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
| 15 #include "chromeos/dbus/audio_node.h" | 15 #include "chromeos/dbus/audio_node.h" |
| 16 | 16 |
| 17 namespace chromeos { | 17 namespace chromeos { |
| 18 | 18 |
| 19 // Ordered from the highest priority to the lowest. | 19 // Ordered from the highest priority to the lowest. |
| 20 enum AudioDeviceType { | 20 enum AudioDeviceType { |
| 21 AUDIO_TYPE_HEADPHONE, | 21 AUDIO_TYPE_HEADPHONE, |
| 22 AUDIO_TYPE_MIC, | 22 AUDIO_TYPE_MIC, |
| 23 AUDIO_TYPE_USB, | 23 AUDIO_TYPE_USB, |
| 24 AUDIO_TYPE_BLUETOOTH, | 24 AUDIO_TYPE_BLUETOOTH, |
| 25 AUDIO_TYPE_HDMI, | 25 AUDIO_TYPE_HDMI, |
| 26 AUDIO_TYPE_INTERNAL_SPEAKER, | 26 AUDIO_TYPE_INTERNAL_SPEAKER, |
| 27 AUDIO_TYPE_INTERNAL_MIC, | 27 AUDIO_TYPE_INTERNAL_MIC, |
| 28 AUDIO_TYPE_FRONT_MIC, |
| 29 AUDIO_TYPE_REAR_MIC, |
| 28 AUDIO_TYPE_KEYBOARD_MIC, | 30 AUDIO_TYPE_KEYBOARD_MIC, |
| 29 AUDIO_TYPE_HOTWORD, | 31 AUDIO_TYPE_HOTWORD, |
| 30 AUDIO_TYPE_LINEOUT, | 32 AUDIO_TYPE_LINEOUT, |
| 31 AUDIO_TYPE_POST_MIX_LOOPBACK, | 33 AUDIO_TYPE_POST_MIX_LOOPBACK, |
| 32 AUDIO_TYPE_POST_DSP_LOOPBACK, | 34 AUDIO_TYPE_POST_DSP_LOOPBACK, |
| 33 AUDIO_TYPE_OTHER, | 35 AUDIO_TYPE_OTHER, |
| 34 }; | 36 }; |
| 35 | 37 |
| 36 struct CHROMEOS_EXPORT AudioDevice { | 38 struct CHROMEOS_EXPORT AudioDevice { |
| 37 AudioDevice(); | 39 AudioDevice(); |
| 38 explicit AudioDevice(const AudioNode& node); | 40 explicit AudioDevice(const AudioNode& node); |
| 39 AudioDevice(const AudioDevice& other); | 41 AudioDevice(const AudioDevice& other); |
| 40 std::string ToString() const; | 42 std::string ToString() const; |
| 41 | 43 |
| 42 // Converts between the string type sent via D-Bus and AudioDeviceType. | 44 // Converts between the string type sent via D-Bus and AudioDeviceType. |
| 43 // Static so they can be used by tests. | 45 // Static so they can be used by tests. |
| 44 static std::string GetTypeString(chromeos::AudioDeviceType type); | 46 static std::string GetTypeString(chromeos::AudioDeviceType type); |
| 45 static chromeos::AudioDeviceType GetAudioType(const std::string& node_type); | 47 static chromeos::AudioDeviceType GetAudioType(const std::string& node_type); |
| 46 | 48 |
| 47 // Indicates that an input or output audio device is for simple usage like | 49 // Indicates that an input or output audio device is for simple usage like |
| 48 // playback or recording for user. In contrast, audio device such as | 50 // playback or recording for user. In contrast, audio device such as |
| 49 // loopback, always on keyword recognition (HOTWORD), and keyboard mic are | 51 // loopback, always on keyword recognition (HOTWORD), and keyboard mic are |
| 50 // not for simple usage. | 52 // not for simple usage. |
| 51 bool is_for_simple_usage() const { | 53 bool is_for_simple_usage() const { |
| 52 return (type == AUDIO_TYPE_HEADPHONE || | 54 return (type == AUDIO_TYPE_HEADPHONE || |
| 53 type == AUDIO_TYPE_INTERNAL_MIC || | 55 type == AUDIO_TYPE_INTERNAL_MIC || |
| 56 type == AUDIO_TYPE_FRONT_MIC || |
| 57 type == AUDIO_TYPE_REAR_MIC || |
| 54 type == AUDIO_TYPE_MIC || | 58 type == AUDIO_TYPE_MIC || |
| 55 type == AUDIO_TYPE_USB || | 59 type == AUDIO_TYPE_USB || |
| 56 type == AUDIO_TYPE_BLUETOOTH || | 60 type == AUDIO_TYPE_BLUETOOTH || |
| 57 type == AUDIO_TYPE_HDMI || | 61 type == AUDIO_TYPE_HDMI || |
| 58 type == AUDIO_TYPE_INTERNAL_SPEAKER || | 62 type == AUDIO_TYPE_INTERNAL_SPEAKER || |
| 59 type == AUDIO_TYPE_LINEOUT); | 63 type == AUDIO_TYPE_LINEOUT); |
| 60 } | 64 } |
| 61 | 65 |
| 62 bool is_input = false; | 66 bool is_input = false; |
| 63 | 67 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return true; | 114 return true; |
| 111 } else { | 115 } else { |
| 112 return false; | 116 return false; |
| 113 } | 117 } |
| 114 } | 118 } |
| 115 }; | 119 }; |
| 116 | 120 |
| 117 } // namespace chromeos | 121 } // namespace chromeos |
| 118 | 122 |
| 119 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 123 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| OLD | NEW |