# AudioAttribute ## **Overview** **Related Modules:** [Audio](Audio.md) **Description:** Provides attribute-related APIs for audio rendering or capturing, including functions to obtain frame information and set audio sampling attributes. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Fields

Variable Name

Description

GetFrameSize )(AudioHandle handle, uint64_t *size)

int32_t(* 

Obtains the audio frame size, that is, the length (in bytes) of a frame.

GetFrameCount )(AudioHandle handle, uint64_t *count)

int32_t(* 

Obtains the number of audio frames in the audio buffer.

SetSampleAttributes )(AudioHandle handle, const struct AudioSampleAttributes *attrs)

int32_t(* 

Sets audio sampling attributes.

GetSampleAttributes )(AudioHandle handle, struct AudioSampleAttributes *attrs)

int32_t(* 

Obtains audio sampling attributes.

GetCurrentChannelId )(AudioHandle handle, uint32_t *channelId)

int32_t(* 

Obtains the data channel ID of the audio.

## **Details** ## **Field Documentation** ## GetCurrentChannelId ``` int32_t(* AudioAttribute::GetCurrentChannelId) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint32_t *channelId) ``` **Description:** Obtains the data channel ID of the audio. **Parameters:**

Name

Description

handle Indicates the audio handle.
channelId Indicates the pointer to the data channel ID.
**Returns:** Returns **0** if the data channel ID is obtained; returns a negative value otherwise. ## GetFrameCount ``` int32_t(* AudioAttribute::GetFrameCount) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t *count) ``` **Description:** Obtains the number of audio frames in the audio buffer. **Parameters:**

Name

Description

handle Indicates the audio handle.
count Indicates the pointer to the number of audio frames in the audio buffer.
**Returns:** Returns **0** if the number of audio frames is obtained; returns a negative value otherwise. ## GetFrameSize ``` int32_t(* AudioAttribute::GetFrameSize) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, uint64_t *size) ``` **Description:** Obtains the audio frame size, that is, the length \(in bytes\) of a frame. **Parameters:**

Name

Description

handle Indicates the audio handle.
size Indicates the pointer to the audio frame size (in bytes).
**Returns:** Returns **0** if the audio frame size is obtained; returns a negative value otherwise. ## GetSampleAttributes ``` int32_t(* AudioAttribute::GetSampleAttributes) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, struct [AudioSampleAttributes](AudioSampleAttributes.md) *attrs) ``` **Description:** Obtains audio sampling attributes. **Parameters:**

Name

Description

handle Indicates the audio handle.
attrs Indicates the pointer to the audio sampling attributes, such as the sampling rate, sampling precision, and channel.
**Returns:** Returns **0** if audio sampling attributes are obtained; returns a negative value otherwise. **See also:** [SetSampleAttributes](AudioAttribute.md#a502fe4e4b97cd253244debcc67d45c4d) ## SetSampleAttributes ``` int32_t(* AudioAttribute::SetSampleAttributes) ([AudioHandle](Audio.md#ga18675ddb073465fdeac33a897f675d79) handle, const struct [AudioSampleAttributes](AudioSampleAttributes.md) *attrs) ``` **Description:** Sets audio sampling attributes. **Parameters:**

Name

Description

handle Indicates the audio handle.
attrs Indicates the pointer to the audio sampling attributes to set, such as the sampling rate, sampling precision, and channel.
**Returns:** Returns **0** if the setting is successful; returns a negative value otherwise. **See also:** [GetSampleAttributes](AudioAttribute.md#a2f92d8704ef677a07d664c33342e4318)