Audio Obtaining and Playing
This section describes the API call sequence and precautions for obtaining and playing audios.
Obtaining Audios

- Call hi_mpi_sys_init to initialize the common module.
- Call hi_mpi_ai_set_pub_attr to configure attributes.
- Call hi_mpi_ai_enable to enable an AI device, and call hi_mpi_ai_enable_chn to enable an AI channel.
- Call hi_mpi_ai_get_frame to obtain the recording data for processing, and then call hi_mpi_ai_release_frame to release audio frames. Repeat this step.
- When audio capturing stops, call hi_mpi_ai_disable_chn to disable the channel, and then call hi_mpi_ai_disable to disable the AI device.
- Call hi_mpi_sys_exit to free the initialization resources of the common module.
Playing Audios

- Call hi_mpi_sys_init to initialize the common module.
- Call hi_mpi_ao_set_pub_attr to configure attributes.
- Call hi_mpi_ao_enable to enable an AO device, and call hi_mpi_ao_enable_chn to enable an AO channel.
- Periodically obtain data and call hi_mpi_ao_send_frame to play the audio.
- When the audio playback ends, obtain the current audio delay in the AO channel by calling hi_mpi_ao_get_chn_delay. When the delay becomes 0, disable the AO channel by calling hi_mpi_ao_disable_chn, and then disable the AO device by calling hi_mpi_ao_disable.
- Call hi_mpi_sys_exit to free the initialization resources of the common module.
Parent topic: Media Data Processing (Including Images and Videos)