的API
frameworks/base/media/java/android/media/
public void handleKeyDown(){
adjustSuggestedStreamVolume();
}
public void adjustSuggestedStreamVolume(){
();
}
调用
frameworks/base/media/java/android/media/
public void adjustSuggestedStreamVolume(){
adjustStreamVolume(streamType, direction, flags, callingPackage);
}
public void adjustStreamVolume(){
}
public void handleMessage(){
case MSG_SET_DEVICE_VOLUME:
setDeviceVolume();
}
private void setDeviceVolume(){
mStreamStates[streamType].applyDeviceVolume(device);
}
public void applyDeviceVolume(){
(mStreamType, index, device);
}
3.调用AudioSystem接口
frameworks/base/media/java/android/media/
public static native int setStreamVolumeIndex();
frameworks/av/media/libmedia/
status_t AudioSystem::setStreamVolumeIndex(){
return aps->setStreamVolumeIndex();
}
4.服务端
frameworks/av/services/audioflinger/
status_t AudioPolicyService::setStreamVolumeIndex(){
return mpAudioPolicy->set_stream_volume_index();
}
hardware/libhardware_legacy/audio/audio_policy_hal.cpp
static int ap_set_stream_volume_index(){
return lap->apm->setStreamVolumeIndex();
}
hardware/libhardware_legacy/audio/
status_t AudioPolicyManagerBase::setStreamVolumeIndex(){
checkAndSetVolume();
}
status_t AudioPolicyManagerBase::checkAndSetVolume(){
float volume = computeVolume();
mpClientInterface->setStreamVolume();
}
hardware/libhardware_legacy/audio/
void AudioPolicyCompatClient::setStreamVolume(){
return mServiceOps->set_stream_volume();
}
frameworks/av/services/audioflinger/
static int aps_set_stream_volume(){
return audioPolicyService->setStreamVolume();
}
int AudioPolicyService::setStreamVolume(){
return (int)mAudioCommandThread->volumeCommand();
}
bool AudioPolicyService::AudioCommandThread::threadLoop(){
case SET_VOLUME:{
AudioSystem::setStreamVolume();
}
}
frameworks/av/media/libmedia/
status_t AudioSystem::setStreamVolume(){
af->setStreamVolume();
}
frameworks/av/services/audioflinger/
status_t AudioFlinger::setStreamVolume(){
(i)->setStreamVolume();
}