In the audio system, the call flowchart of the getoutput function for setting the sound output device is as follows:
There is only one derived class for audiopolicyclientinterface, that is, the audiopolicyservice class. The base classes of audiopolicyservice are defined as follows:
Class audiopolicyservice: Public bnaudiopolicyservice, public audiopolicyclientinterface, public ibinder: deathrecipient {
Therefore, the audiopolicymanagerbase: getoutput function calls the openoutput function of the member variable of the audiopolicyclientinterface interface type, which is actually called the audiopolicyservice: getoutput function.
The audiotrack: getoutput function is called in the audiotrack: Start () and audiotrack: obtainbuffer functions.
The audiotrack: Start () function is called in the mediaplayerservice: audiooutput: Start () function.
For the relationship between audiotrack and mediaplayer, refer:Process of creating audiotrack in mediaplayer
In addition, audioflinger's internal class playbackthread also contains the getoutput function, which returns an audio output hardware abstract interface class audiostreamout object.
There are four Derived classes for the interface class audiostreamout, which are:
Audiostreamoutdump, audiostreamoutalsa, audiostreamoutgeneric, and audiostreamoutstub.