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

- Initialize the public media module by calling hi_mpi_sys_init.
- Invoke the hi_mpi_ai_set_pub_attr interface to configure attributes.
- Enable the AI device by calling the hi_mpi_ai_enable interface and enable the AI channel by calling the hi_mpi_ai_enable_chn interface.
- 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. The process repeats.
- When the AI device stops capturing audio, call the hi_mpi_ai_disable_chn interface to disable the channel, and then call the hi_mpi_ai_disable interface to disable the AI device.
- Call the hi_mpi_sys_exit interface to release the initialization resources of the common media module.
Playing Audios

- Initialize the public media module by calling hi_mpi_sys_init.
- Invoke the hi_mpi_ao_set_pub_attr interface to configure attributes.
- Enable the AO device by calling the hi_mpi_ao_enable interface, and enable the AO channel by calling the hi_mpi_ao_enable_chn interface.
- Periodically obtain data and call the hi_mpi_ao_send_frame API to play audio.
- When the audio playback is complete, call hi_mpi_ao_get_chn_delay to obtain the current audio delay of the AO channel. When the delay is 0, call hi_mpi_ao_disable_chn to disable the channel, and then call hi_mpi_ao_disable to disable the AO device.
- Call the hi_mpi_sys_exit interface to release the initialization resources of the common media module.
Parent topic: Media Data Processing V2