Audio data path in a variety of video scenarios on Android smartphones

Source: Internet
Author: User

The previous article (an analysis of audio on Android smartphones) said this article will explain in detail the flow of audio data in the various audio scenarios in Android smartphones, and we'll start now. The main scenes of audio in smartphones are audio playback, audio recording, voice communication, and so on. There is a great difference in the flow of audio data in different scenarios, even in the same scenario, where the flow of audio data varies in different modes.

1, audio playback

There are three main playback modes in the Android Audio framework: Low latency playback, deep buffer playback, and compressed offload playback.

A) Low latency playback: for voice output with high latency required for key tones, game background sounds, etc. The audio file is decoded into PCM data on the AP side and then sent to the codec chip via audio DSP.

b) deep buffer playback: For music and other low latency requirements of the sound output. Audio files are decoded into PCM data on the AP side and, if they have sound effects, will be processed to the PCM (with the effect sound module in the Android audio framework, with equalizer, bass boost, surround sound, etc.), and then via audio The DSP sends the codec chip to play out.

c) Compressed offload playback: for music and other sound output, but the audio decoding part of the work is completed in audio DSP, the AP side is only responsible for the audio stream sent to the Audo DSP, sent out after the AP side will sleep, Audo The DSP will allocate a larger buffer to process this data, decoding in the Audo DSP, sound processing, etc., before the Audo DSP decoder finishes processing data, it wakes the AP side to send the next packet of data. Playing audio in this mode can effectively reduce power consumption and is the most recommended mode for playing music. But in the current mainstream music play app is basically a deep buffer playback mode, such as QQ music, NetEase cloud music and cool dog music. It seems that the system platform vendors and app vendors approach is different. As to which format the music plays in this mode, which needs to be controlled in Audiopolicy, the platform I do is MP3 (*.mp3) and AAC (*.M4A) play in offload mode, because these two formats are the most mainstream.

Both the low latency mode and the deep buffer mode are sent PCM data to audio DSP after the AP side decoding, so the audio data flow is similar, I will put together, and compressed offload mode is the code stream to audio DSP decoding. Play the system and game tones with low latency mode , play the music with deep buffer or compressed offload mode, play the recording in deep buffer mode. Next we look at the audio data flow in the low latency/deep buffer and compressed offload two modes. Audio data is only passed through the AP and audio DSP when playing.

1) Audio data flow in low latency/deep buffer mode

From the point of See, the audio file first on the AP soft decoding to get PCM after audiotrack/audioflinger in the mixer thread (it is possible to do the sound after processing)/audio Hal/tinyalsa sent to kernel, Then use the IPC to send the PCM to audio DSP after the re-sampling mix and so on play out. The audio DSP does not need to be done because it has been decoded and the audio is processed on the AP.

2) Compressed audio data flow in offload mode

From the point of See, the audio stream passes through the Audiotrack/audioflinger in the AP offload thread (do not need to do the sound after processing)/audio Hal/tinyalsa sent to kernel, and then use IPC to stream the code to audio DSP after decoding, post-processing, resampling, mixing and so on play out.

2, audio recording

Many people like to record the audio of an important meeting or speech in order to repeat or use it. is the flow of audio data when recording. As with audio playback, audio data is also only passed through the AP and voice DSP when recording.

From the codec chip, the PCM data is sent to the audio DSP after resampling, pre-processing to the AP kernel, and then through the Tinyalsa/audio Hal/audioflinger record thread/ Audiorecord after doing the soft code to get the audio stream file and keep up.

3, Voice communication

Voice communication is called. It is not the same as audio playback or recording, it is bidirectional, sub-uplink (uplink, the acquisition of the voice sent to the other side) and the downlink (downlink, the received voice playback), and audio playback or recording is one-way. Its audio data flow is not the same as audio playback or recording, only through audio DSP and CP, that is, the direction of the audio data on the phone.

From See, in the upstream direction of the codec chip collected PCM data sent to audio DSP after resampling, pre-processing (AEC/ANS/AGC, etc.), encoded to get the code stream, and the code stream to CP,CP processing after the air interface sent to each other. In the downstream direction from the interface to receive the other side of the voice data sent, and do network side processing (jitter buffer, etc.), and then sent to Audio Dsp,audio DSP received after doing decoding, post-processing (ANS/AGC, etc.), resampling, and then the PCM data by dma/ I2S sent to codec chip to play out.

Audio data path in a variety of video scenarios on Android smartphones

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.