| 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_KEYBOARD_MIC, | 28 AUDIO_TYPE_KEYBOARD_MIC, |
| 29 AUDIO_TYPE_HOTWORD, | 29 AUDIO_TYPE_HOTWORD, |
| 30 AUDIO_TYPE_LINEOUT, |
| 30 AUDIO_TYPE_POST_MIX_LOOPBACK, | 31 AUDIO_TYPE_POST_MIX_LOOPBACK, |
| 31 AUDIO_TYPE_POST_DSP_LOOPBACK, | 32 AUDIO_TYPE_POST_DSP_LOOPBACK, |
| 32 AUDIO_TYPE_OTHER, | 33 AUDIO_TYPE_OTHER, |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 struct CHROMEOS_EXPORT AudioDevice { | 36 struct CHROMEOS_EXPORT AudioDevice { |
| 36 AudioDevice(); | 37 AudioDevice(); |
| 37 explicit AudioDevice(const AudioNode& node); | 38 explicit AudioDevice(const AudioNode& node); |
| 38 AudioDevice(const AudioDevice& other); | 39 AudioDevice(const AudioDevice& other); |
| 39 std::string ToString() const; | 40 std::string ToString() const; |
| 40 | 41 |
| 41 // Converts between the string type sent via D-Bus and AudioDeviceType. | 42 // Converts between the string type sent via D-Bus and AudioDeviceType. |
| 42 // Static so they can be used by tests. | 43 // Static so they can be used by tests. |
| 43 static std::string GetTypeString(chromeos::AudioDeviceType type); | 44 static std::string GetTypeString(chromeos::AudioDeviceType type); |
| 44 static chromeos::AudioDeviceType GetAudioType(const std::string& node_type); | 45 static chromeos::AudioDeviceType GetAudioType(const std::string& node_type); |
| 45 | 46 |
| 46 // Indicates that an input or output audio device is for simple usage like | 47 // Indicates that an input or output audio device is for simple usage like |
| 47 // playback or recording for user. In contrast, audio device such as | 48 // playback or recording for user. In contrast, audio device such as |
| 48 // loopback, always on keyword recognition (HOTWORD), and keyboard mic are | 49 // loopback, always on keyword recognition (HOTWORD), and keyboard mic are |
| 49 // not for simple usage. | 50 // not for simple usage. |
| 50 bool is_for_simple_usage() const { | 51 bool is_for_simple_usage() const { |
| 51 return (type == AUDIO_TYPE_HEADPHONE || | 52 return (type == AUDIO_TYPE_HEADPHONE || |
| 52 type == AUDIO_TYPE_INTERNAL_MIC || | 53 type == AUDIO_TYPE_INTERNAL_MIC || |
| 53 type == AUDIO_TYPE_MIC || | 54 type == AUDIO_TYPE_MIC || |
| 54 type == AUDIO_TYPE_USB || | 55 type == AUDIO_TYPE_USB || |
| 55 type == AUDIO_TYPE_BLUETOOTH || | 56 type == AUDIO_TYPE_BLUETOOTH || |
| 56 type == AUDIO_TYPE_HDMI || | 57 type == AUDIO_TYPE_HDMI || |
| 57 type == AUDIO_TYPE_INTERNAL_SPEAKER); | 58 type == AUDIO_TYPE_INTERNAL_SPEAKER || |
| 59 type == AUDIO_TYPE_LINEOUT); |
| 58 } | 60 } |
| 59 | 61 |
| 60 bool is_input; | 62 bool is_input; |
| 61 | 63 |
| 62 // Id of this audio device. The legacy |id| is assigned to be unique everytime | 64 // Id of this audio device. The legacy |id| is assigned to be unique everytime |
| 63 // when each device got plugged, so that the same physical device will have | 65 // when each device got plugged, so that the same physical device will have |
| 64 // a different id after unplug then re-plug. | 66 // a different id after unplug then re-plug. |
| 65 // The |stable_device_id| is designed to be persistent across system reboot | 67 // The |stable_device_id| is designed to be persistent across system reboot |
| 66 // and plug/unplug for the same physical device. It is guaranteed that | 68 // and plug/unplug for the same physical device. It is guaranteed that |
| 67 // different type of hardware has different |stable_device_id|, but not | 69 // different type of hardware has different |stable_device_id|, but not |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return true; | 101 return true; |
| 100 } else { | 102 } else { |
| 101 return false; | 103 return false; |
| 102 } | 104 } |
| 103 } | 105 } |
| 104 }; | 106 }; |
| 105 | 107 |
| 106 } // namespace chromeos | 108 } // namespace chromeos |
| 107 | 109 |
| 108 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ | 110 #endif // CHROMEOS_AUDIO_AUDIO_DEVICE_H_ |
| OLD | NEW |