Using SourceInsight to study the android source code, I saw such a place.
status_t AudioPolicyManager::startOutput(audio_io_handle_t output,
audio_stream_type_t stream,
audio_session_t session)
{
//前面省略
//就是这个地方,真讨厌!!!!!!1
ALOGV("before startSource");
status_t status = startSource(outputDesc, stream, newDevice, &delayMs);
ALOGV("after startSource");
//以下省略
}
Code location: frameworks/av/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
Did you see it? It is a startSource function, I click and jump to
status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc,
audio_stream_type_t stream,
audio_devices_t device,
uint32_t *delayMs)
{
ALOGV("AudioPolicyManager::startSource()");
As a result, the called log cannot be printed out. It's really been a long time to see you, hell. I searched in the current directory and nearby directories. Just didn't see any other implementation. Strange.
Finally found one
class AudioPolicyManagerCustom: public AudioPolicyManager
There are really subcategories . there really are
startSource
And the same name. The number of parameters is the same, and the parameter types are the same.
Well, back to the definition of the AudioPolicyManager class
virtual status_t startSource(sp<AudioOutputDescriptor> outputDesc,
audio_stream_type_t stream,
audio_devices_t device,
uint32_t *delayMs);
virtual function
Things are here, basically clear.
Ok, now turn to the C++ primer, xxxx page, and review the knowledge covered by C++:
Well, I can’t take a screenshot, and the book is not with me, so just pick one up:
覆盖是指派生类函数覆盖基类函数,特征是:
(1)不同的范围(分别位于派生类与基类);
(2)函数名字相同;
(3)参数相同;
(4)基类函数必须有virtual 关键字。
Now I understand that the reason for the weird phenomenon I have seen is that the coverage has occurred
In addition, the calling place is actually called with pointers (many ready-made examples are written with pointers), and there is a hidden this pointer in this place.
What good would it do? For example, let’s talk about the Andorid system. Google has given a standard version. You don’t have to change the original system. You can write a class yourself and overwrite the original class. This is customization.