1# native_audio_device_base.h
2
3
4## Overview
5
6The **native_audio_device_base.h** file declares the types of audio device parameters and the functions for obtaining these parameters.
7
8**Library**: libohaudio.so
9
10**File to include**: <ohaudio/native_audio_device_base.h>
11
12**System capability**: SystemCapability.Multimedia.Audio.Core
13
14**Since**: 12
15
16**Related module**: [OHAudio](_o_h_audio.md)
17
18
19## Summary
20
21
22### Structs
23
24| Name| Description|
25| -------- | -------- |
26| struct  [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) | Describes an array of audio device descriptors. |
27
28
29### Types
30
31| Name| Description|
32| -------- | -------- |
33| typedef struct [OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) [OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) | Defines a struct for an audio device descriptor. It provides detailed attributes of an audio device. |
34| typedef struct [OH_AudioDeviceDescriptorArray](_o_h___audio_device_descriptor_array.md) [OH_AudioDeviceDescriptorArray](_o_h_audio.md#oh_audiodevicedescriptorarray) | Defines a struct for an array of audio device descriptors. |
35
36
37### Enums
38
39| Name| Description|
40| -------- | -------- |
41| [OH_AudioDevice_ChangeType](_o_h_audio.md#oh_audiodevice_changetype) {<br>AUDIO_DEVICE_CHANGE_TYPE_CONNECT = 0,<br>AUDIO_DEVICE_CHANGE_TYPE_DISCONNECT = 1<br>} | Enumerates the types of audio device changes.|
42| [OH_AudioDevice_Role](_o_h_audio.md#oh_audiodevice_role) {<br>AUDIO_DEVICE_ROLE_INPUT = 1,<br>AUDIO_DEVICE_ROLE_OUTPUT = 2<br>} | Enumerates the roles of audio devices.|
43| [OH_AudioDevice_Type](_o_h_audio.md#oh_audiodevice_type) {<br>AUDIO_DEVICE_TYPE_INVALID = 0,<br>AUDIO_DEVICE_TYPE_EARPIECE = 1,<br>AUDIO_DEVICE_TYPE_SPEAKER = 2,<br>AUDIO_DEVICE_TYPE_WIRED_HEADSET = 3,<br>AUDIO_DEVICE_TYPE_WIRED_HEADPHONES = 4,<br>AUDIO_DEVICE_TYPE_BLUETOOTH_SCO = 7,<br>AUDIO_DEVICE_TYPE_BLUETOOTH_A2DP = 8,<br>AUDIO_DEVICE_TYPE_MIC = 15,<br>AUDIO_DEVICE_TYPE_USB_HEADSET = 22,<br>AUDIO_DEVICE_TYPE_DISPLAY_PORT = 23,<br>AUDIO_DEVICE_TYPE_REMOTE_CAST = 24,<br>AUDIO_DEVICE_TYPE_DEFAULT = 1000<br>} | Enumerates the types of audio devices.|
44| [OH_AudioDevice_Flag](_o_h_audio.md#oh_audiodevice_flag) {<br>AUDIO_DEVICE_FLAG_NONE = 0,<br>AUDIO_DEVICE_FLAG_OUTPUT = 1,<br>AUDIO_DEVICE_FLAG_INPUT = 2,<br>AUDIO_DEVICE_FLAG_ALL = 3<br>} | Enumerates the flags of audio devices.|
45| [OH_AudioDevice_Usage](_o_h_audio.md#oh_audiodevice_usage) {<br>AUDIO_DEVICE_USAGE_MEDIA_OUTPUT = 1, <br>AUDIO_DEVICE_USAGE_MEDIA_INPUT = 2, <br>AUDIO_DEVICE_USAGE_MEDIA_ALL = 3, <br>AUDIO_DEVICE_USAGE_CALL_OUTPUT = 4,<br>AUDIO_DEVICE_USAGE_CALL_INPUT = 8, <br>AUDIO_DEVICE_USAGE_CALL_ALL = 12<br>} | Enumerates the usage scenarios of audio devices. |
46| [OH_AudioDevice_BlockStatus](_o_h_audio.md#oh_audiodevice_blockstatus) { <br>AUDIO_DEVICE_UNBLOCKED = 0, <br>AUDIO_DEVICE_BLOCKED = 1 } | Enumerates the blocked status of audio devices. By default, an audio device is not blocked.|
47
48
49### Functions
50
51| Name| Description|
52| -------- | -------- |
53| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceRole](_o_h_audio.md#oh_audiodevicedescriptor_getdevicerole)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, [OH_AudioDevice_Role](_o_h_audio.md#oh_audiodevice_role) \*deviceRole) | Obtains the device role based on an audio device descriptor.|
54| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceType](_o_h_audio.md#oh_audiodevicedescriptor_getdevicetype)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, [OH_AudioDevice_Type](_o_h_audio.md#oh_audiodevice_type) \*deviceType) | Obtains the device type based on an audio device descriptor.|
55| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceId](_o_h_audio.md#oh_audiodevicedescriptor_getdeviceid)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, uint32_t \*id) | Obtains the device ID based on an audio device descriptor.|
56| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceName](_o_h_audio.md#oh_audiodevicedescriptor_getdevicename)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, char \*\*name) | Obtains the device name based on an audio device descriptor.|
57| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceAddress](_o_h_audio.md#oh_audiodevicedescriptor_getdeviceaddress)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, char \*\*address) | Obtains the device address based on an audio device descriptor.|
58| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceSampleRates](_o_h_audio.md#oh_audiodevicedescriptor_getdevicesamplerates)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, uint32_t \*\*sampleRates, uint32_t \*size) | Obtains the sample rates based on an audio device descriptor.|
59| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceChannelCounts](_o_h_audio.md#oh_audiodevicedescriptor_getdevicechannelcounts)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, uint32_t \*\*channelCounts, uint32_t \*size) | Obtains an array that holds the number of device channels based on an audio device descriptor.|
60| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceDisplayName](_o_h_audio.md#oh_audiodevicedescriptor_getdevicedisplayname)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, char \*\*displayName) | Obtains the device display name based on an audio device descriptor.|
61| [OH_AudioCommon_Result](_o_h_audio.md#oh_audiocommon_result) [OH_AudioDeviceDescriptor_GetDeviceEncodingTypes](_o_h_audio.md#oh_audiodevicedescriptor_getdeviceencodingtypes)([OH_AudioDeviceDescriptor](_o_h_audio.md#oh_audiodevicedescriptor) \*audioDeviceDescriptor, [OH_AudioStream_EncodingType](_o_h_audio.md#oh_audiostream_encodingtype) \*\*encodingTypes, uint32_t \*size) | Obtains the device encoding types based on an audio device descriptor.|
62