hi_mpi_ao_send_frame

Applicability

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Description

Sends AO audio frames.

Prototype

hi_s32 hi_mpi_ao_send_frame(hi_audio_dev ao_dev, hi_ao_chn ao_chn, const hi_audio_frame *data, hi_s32 milli_sec)

Parameters

Parameter

Input/Output

Description

ao_dev

Input

Audio device ID. The value range is [0, 4].

ao_chn

Input

AO channel ID.

data

Input

Audio frame structure.

milli_sec

Input

Timeout interval for sending data (ms).

  • -1: blocking mode. The wait is infinite if there is no data.
  • 0: non-blocking mode. An error is returned if there is no data.
  • > 0: A specific timeout interval needs to be configured. If no data is found after the specified interval, an error is returned.

Returns

Restrictions

  • This API is used to actively send audio frames to the AO channel.
  • Before calling this API to send audio frames to the AO channel, call hi_mpi_ao_enable_chn to enable the corresponding AO channel.
  • When the audio-left channel or stereo channel is used for playing, ai_chn must be fixed at 0. When the audio-right channel is used for recording, ai_chn is 1.
  • The member variables len and virt_addr of the audio frame structure must match each other. len indicates the frame length (in bytes), and virt_addr indicates the address of the input audio data. It is recommended that the data transferred each time be a frame. That is, len equals point_num_per_frame multiplied by the bit width (2 bytes = 16 bits; 3 bytes = 24 bits).
  • The limit on len: Calculate the number of data points based on len and the bit width (Number of data points = len/Number of bytes corresponding to the bit width). The range of the number of data points is [1, frame_num × point_num_per_frame], and the maximum value is 4096.
    • Example 1: If frame_num = 2 and point_num_per_frame = 480 (for details about the range limit on frame_num and point_num_per_frame, see hi_aio_attr), frame_num × point_num_per_frame = 960. As 960 < 4096, the range of the number of data points is [1, 960].
    • Example 2: If frame_num = 30 and point_num_per_frame = 4096, frame_num × point_num_per_frame = 122880. As 122880 > 4096, the range of the number of data points is [1, 4096].
    • Example 3: When the range of data points determined based on frame_num and point_num_per_frame is [1, 960]: If len = 960 and the bit width is 16 bits (2 bytes), the calculated number of data points is 960/2 = 480. The value is within the range of [1, 960] and meets the requirement. If len = 3840 and the bit width is 16 bits (2 bytes), the calculated number of data points is 3840/2 = 1920. The value is beyond the range of [1, 960]and an error is reported.

See Also

For the API call sequence, see Audio Obtaining and Playing.