Long time no blog, recently organized the next picture of the flowchart and description, this is about Android5.0 new patch Panel, using the audio patch mechanism to achieve, is so-called have a picture of the truth, see the figure.
Path to Patch panel:frameworks/av/services/audioflinger/patchpanel.cpp
- Patch panel-related structures:
An audio patch is used to represent one or more source ends to one or more sink ends. This is from the code of the comments translated, you can compare it to a dam, you can have several inlet and outlet, each time the water storage and waterproof inlet and outlet of the number can be different, such as a inlet and two outlet. The actual scenario is that an audio file is played into the speakers and headphones, or two microphones record the left and right channels into an audio file.
Applications can also use this feature directly, but only if the permission is first: Android.permission.MODIFY_AUDIO_ROUTING
Just like that. An audio patch has multiple source ends and multiple sink ends, so there are two arrays in the audio_patch structure, where each port is a audio_port.
This port contains some basic parameters for basic needs, including stream and device. Let's see the name of the brain to fill it.
Some new functions are listed:
Each audio_patch is generated in Audioflinger via the parameters specified by the APS and is Audiohal processed by the Audioflinger call.
(The red line is the process of creation, Blue is the process)
- Audio Patch Usage Scenario (1): Mix stream plays to multiple devices i.e. hardware
Generally used in Setoutputdevice, replace the original Setparameters way.
Flowchart or something:
- Usage Scenario (2): Device to mix, which is a recording from a hardware device to an audio track.
LP5.0 the new Setintputdevice to replace the original output of the things done, here will use this scene.
Flow chart:
- Usage Scenario (3): Device to device, this is more difficult to understand, familiar with audio can be seen as two HAL through Audioflinger data, the middle does not go encoder what the processing.
Flow chart:
Here to say the two device between the buffer (now track in the LP5.0 has been changed, but also includes the space application method to cater to the use of the scene), specific please look at the picture, a long time ago, I also feel that it is not clear.
Flow chart:
- We can see a concrete implementation to understand this thing: using a USB device to make a phone call
(provided that the USB cable is not connected to your codec, and the phone data is connected to your codec, a bit around the mouth, the specific view)
Of course, this is Google's own work, not my use of the scene ... Our great Eric Big wet!
Some of the new functions and variables:
Painting for a long time barely able to read:
The effect is as follows:
The TX data is path from the USB device via two lines to the remote of the CP phone.
Rx data from the remote of the CP phone via two wire path to the USB device.
Simple flowchart:
- Audio patch can also adjust the volume:
And the app can also adjust the volume directly, each volume adjustment is also a audio_patch, then the HAL is processed.
This is Google's job:
(Map of the map is our very good very powerful universe first ultra-high-performance inverse of the unique DSP processor ):
Flow chart:
Sorry, the blow is over, no ... END
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Some analysis of audio patch and patch panel on Android5.0