捋一捋代码流程:
上层流程之前有分析过,可以参考这个:
https://blog.csdn.net/bberdong/article/details/51792319(抱歉,那时候写的太随意)
咱们就从AudioPolicyManager::checkAndSetVolume说起:
status_t AudioPolicyManager::checkAndSetVolume(
audio_stream_type_t stream,
int index,
const sp<AudioOutputDescriptor>& outputDesc,
audio_devices_t device,
int delayMs,
bool force)
{
...
if (stream == AUDIO_STREAM_VOICE_CALL ||
stream == AUDIO_STREAM_BLUETOOTH_SCO) {
float voiceVolume;
// Force voice volume to max for bluetooth SCO as volume is managed by the headset
if (stream == AUDIO_STREAM_VOICE_CALL) {
voiceVolume = (float)index/(float)mVolumeCurves->getVolumeIndexMax(stream);
} else {
voiceVolume = 1.0;
}
if (voiceVolume != m