# AudioAdapter - [Overview](#section611392098165630) - [Summary](#section1187227500165630) - [Data Fields](#pub-attribs) - [Details](#section2025801532165630) - [Field](#section1769083627165630) - [CreateCapture](#a8a46358cdad8e0a9d15ac079713535f2) - [CreateRender](#a284ea2ad18ebac562ca7283652e61b50) - [DestroyCapture](#a1175a27c5273dab1acf8f8f3c4967637) - [DestroyRender](#a070a8d60f88134c58c4439d4419af913) - [GetPassthroughMode](#ad4c41f3193c5ec3da254f33e24241ea6) - [GetPortCapability](#a525ec7f3f3bb9975790e27f75145d0f6) - [InitAllPorts](#a3c46c9291d4c08d489454ffd78d4a1ee) - [SetPassthroughMode](#ac4e77085cdcc853de832a2b16b8dc69a) ## **Overview** **Related Modules:** [Audio](audio.md) **Description:** Provides audio adapter capabilities, including initializing ports, creating rendering and capturing tasks, and obtaining the port capability set. See also : [AudioRender](audiorender.md) : [AudioCapture](audiocapture.md) **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Fields

Variable Name

Description

InitAllPorts )(struct AudioAdapter *adapter)

int32_t(*

Initializes all ports of an audio adapter.

CreateRender )(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, const struct AudioSampleAttributes *attrs, struct AudioRender **render)

int32_t(*

Creates an AudioRender object.

DestroyRender )(struct AudioAdapter *adapter, struct AudioRender *render)

int32_t(*

Destroys an AudioRender object.

CreateCapture )(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc, const struct AudioSampleAttributes *attrs, struct AudioCapture **capture)

int32_t(*

Creates an AudioCapture object.

DestroyCapture )(struct AudioAdapter *adapter, struct AudioCapture *capture)

int32_t(*

Destroys an AudioCapture object.

GetPortCapability )(struct AudioAdapter *adapter, const struct AudioPort *port, struct AudioPortCapability *capability)

int32_t(*

Obtains the capability set of the port driver for the audio adapter.

SetPassthroughMode )(struct AudioAdapter *adapter, const struct AudioPort *port, enum AudioPortPassthroughMode mode)

int32_t(*

Sets the passthrough data transmission mode of the audio port driver.

GetPassthroughMode )(struct AudioAdapter *adapter, const struct AudioPort *port, enum AudioPortPassthroughMode *mode)

int32_t(*

Obtains the passthrough data transmission mode of the audio port driver.

## **Details** ## **Field ** ## CreateCapture ``` int32_t(* AudioAdapter::CreateCapture) (struct [AudioAdapter](audioadapter.md) *adapter, const struct [AudioDeviceDescriptor](audiodevicedescriptor.md) *desc, const struct [AudioSampleAttributes](audiosampleattributes.md) *attrs, struct [AudioCapture](audiocapture.md) **capture) ``` **Description:** Creates an **[AudioCapture](audiocapture.md)** object. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
desc Indicates the pointer to the descriptor of the audio adapter to start.
attrs Indicates the pointer to the audio sampling attributes to open.
capture Indicates the double pointer to the AudioCapture object.
**Returns:** Returns **0** if the **[AudioCapture](audiocapture.md)** object is created successfully; returns a negative value otherwise. **See also:** [GetPortCapability](audioadapter.md#a525ec7f3f3bb9975790e27f75145d0f6) [DestroyCapture](audioadapter.md#a1175a27c5273dab1acf8f8f3c4967637) ## CreateRender ``` int32_t(* AudioAdapter::CreateRender) (struct [AudioAdapter](audioadapter.md) *adapter, const struct [AudioDeviceDescriptor](audiodevicedescriptor.md) *desc, const struct [AudioSampleAttributes](audiosampleattributes.md) *attrs, struct [AudioRender](audiorender.md) **render) ``` **Description:** Creates an **[AudioRender](audiorender.md)** object. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
desc Indicates the pointer to the descriptor of the audio adapter to start.
attrs Indicates the pointer to the audio sampling attributes to open.
render Indicates the double pointer to the AudioRender object.
**Returns:** Returns **0** if the **[AudioRender](audiorender.md)** object is created successfully; returns a negative value otherwise. **See also:** [GetPortCapability](audioadapter.md#a525ec7f3f3bb9975790e27f75145d0f6) [DestroyRender](audioadapter.md#a070a8d60f88134c58c4439d4419af913) ## DestroyCapture ``` int32_t(* AudioAdapter::DestroyCapture) (struct [AudioAdapter](audioadapter.md) *adapter, struct [AudioCapture](audiocapture.md) *capture) ``` **Description:** Destroys an **[AudioCapture](audiocapture.md)** object. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
capture Indicates the pointer to the AudioCapture object to operate.
**Attention:** Do not destroy the object during audio capturing. **Returns:** Returns **0** if the **[AudioCapture](audiocapture.md)** object is destroyed; returns a negative value otherwise. **See also:** [CreateCapture](audioadapter.md#a8a46358cdad8e0a9d15ac079713535f2) ## DestroyRender ``` int32_t(* AudioAdapter::DestroyRender) (struct [AudioAdapter](audioadapter.md) *adapter, struct [AudioRender](audiorender.md) *render) ``` **Description:** Destroys an **[AudioRender](audiorender.md)** object. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
render Indicates the pointer to the AudioRender object to operate.
**Attention:** Do not destroy the object during audio rendering. **Returns:** Returns **0** if the **[AudioRender](audiorender.md)** object is destroyed; returns a negative value otherwise. **See also:** [CreateRender](audioadapter.md#a284ea2ad18ebac562ca7283652e61b50) ## GetPassthroughMode ``` int32_t(* AudioAdapter::GetPassthroughMode) (struct [AudioAdapter](audioadapter.md) *adapter, const struct [AudioPort](audioport.md) *port, enum [AudioPortPassthroughMode](audio.md#ga186d2d4f9a2ecacb80cd2cce2bd26f0e) *mode) ``` **Description:** Obtains the passthrough data transmission mode of the audio port driver. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
port Indicates the pointer to the port.
mode Indicates the pointer to the passthrough transmission mode to obtain.
**Returns:** Returns **0** if the mode is successfully obtained; returns a negative value otherwise. **See also:** [SetPassthroughMode](audioadapter.md#ac4e77085cdcc853de832a2b16b8dc69a) ## GetPortCapability ``` int32_t(* AudioAdapter::GetPortCapability) (struct [AudioAdapter](audioadapter.md) *adapter, const struct [AudioPort](audioport.md) *port, struct [AudioPortCapability](audioportcapability.md) *capability) ``` **Description:** Obtains the capability set of the port driver for the audio adapter. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
port Indicates the pointer to the port.
capability Indicates the pointer to the capability set to obtain.
**Returns:** Returns **0** if the capability set is successfully obtained; returns a negative value otherwise. ## InitAllPorts ``` int32_t(* AudioAdapter::InitAllPorts) (struct [AudioAdapter](audioadapter.md) *adapter) ``` **Description:** Initializes all ports of an audio adapter. Call this function before calling other driver functions to check whether the initialization is complete. If the initialization is not complete, wait for a while \(for example, 100 ms\) and perform the check again until the port initialization is complete. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
**Returns:** Returns **0** if the initialization is successful; returns a negative value otherwise. ## SetPassthroughMode ``` int32_t(* AudioAdapter::SetPassthroughMode) (struct [AudioAdapter](audioadapter.md) *adapter, const struct [AudioPort](audioport.md) *port, enum [AudioPortPassthroughMode](audio.md#ga186d2d4f9a2ecacb80cd2cce2bd26f0e) mode) ``` **Description:** Sets the passthrough data transmission mode of the audio port driver. **Parameters:**

Name

Description

adapter Indicates the pointer to the audio adapter to operate.
port Indicates the pointer to the port.
mode Indicates the passthrough transmission mode to set.
**Returns:** Returns **0** if the setting is successful; returns a negative value otherwise. **See also:** [GetPassthroughMode](audioadapter.md#ad4c41f3193c5ec3da254f33e24241ea6)