author | Zhenggang Luo <zhenggang.luo@amlogic.com> | 2015-02-03 10:30:09 (GMT) |
---|---|---|
committer | Zhenggang Luo <zhenggang.luo@amlogic.com> | 2015-02-03 10:44:08 (GMT) |
commit | 39a7c235ab6f04927119285322a305e07faaa620 (patch) | |
tree | d188d607552455d36ead0d700457fba9f82ab10d | |
parent | 216adc349ccb2083f3ec91a8345b4a62a9aa1f7e (diff) | |
download | audio-39a7c235ab6f04927119285322a305e07faaa620.zip audio-39a7c235ab6f04927119285322a305e07faaa620.tar.gz audio-39a7c235ab6f04927119285322a305e07faaa620.tar.bz2 |
PD #103162: fix STRATEGY_MEDIA volume settng issue
STRATEGY_MEDIA volume settng was changed when switch video:
fix it by reload AudioPolicyManager::getNewOutputDevice() and force changed
device type from AUDIO_DEVICE_OUT_AUX_DIGITAL to
AUDIO_DEVICE_OUT_SPEAKER
Change-Id: I6d482568529d3920e264d19c70c097a36f0093dc
-rw-r--r--[-rwxr-xr-x] | DLGAudioPolicyManager.cpp | 73 | ||||
-rw-r--r-- | DLGAudioPolicyManager.h | 1 |
2 files changed, 74 insertions, 0 deletions
diff --git a/DLGAudioPolicyManager.cpp b/DLGAudioPolicyManager.cpp index adb2a50..7d0bc78 100755..100644 --- a/DLGAudioPolicyManager.cpp +++ b/DLGAudioPolicyManager.cpp @@ -468,6 +468,79 @@ audio_stream_type_t DLGAudioPolicyManager::streamTypefromAttributesInt(const aud return AUDIO_STREAM_MUSIC; } } +audio_devices_t DLGAudioPolicyManager::getNewOutputDevice(audio_io_handle_t output, bool fromCache) +{ + audio_devices_t device = AUDIO_DEVICE_NONE; + + sp<AudioOutputDescriptor> outputDesc = mOutputs.valueFor(output); + + ssize_t index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle); + if (index >= 0) { + sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index); + if (patchDesc->mUid != mUidCached) { + ALOGV("getNewOutputDevice() device %08x forced by patch %d", + outputDesc->device(), outputDesc->mPatchHandle); + return outputDesc->device(); + } + } + + // check the following by order of priority to request a routing change if necessary: + // 1: the strategy enforced audible is active and enforced on the output: + // use device for strategy enforced audible + // 2: we are in call or the strategy phone is active on the output: + // use device for strategy phone + // 3: the strategy for enforced audible is active but not enforced on the output: + // use the device for strategy enforced audible + // 4: the strategy sonification is active on the output: + // use device for strategy sonification + // 5: the strategy "respectful" sonification is active on the output: + // use device for strategy "respectful" sonification + // 6: the strategy media is active on the output: + // use device for strategy media + // 7: the strategy DTMF is active on the output: + // use device for strategy DTMF + if (outputDesc->isStrategyActive(STRATEGY_ENFORCED_AUDIBLE) && + mForceUse[AUDIO_POLICY_FORCE_FOR_SYSTEM] == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED) { + device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache); + } else if (isInCall() || + outputDesc->isStrategyActive(STRATEGY_PHONE)) { + device = getDeviceForStrategy(STRATEGY_PHONE, fromCache); + } else if (outputDesc->isStrategyActive(STRATEGY_ENFORCED_AUDIBLE)) { + device = getDeviceForStrategy(STRATEGY_ENFORCED_AUDIBLE, fromCache); + } else if (outputDesc->isStrategyActive(STRATEGY_SONIFICATION)) { + device = getDeviceForStrategy(STRATEGY_SONIFICATION, fromCache); + } else if (outputDesc->isStrategyActive(STRATEGY_SONIFICATION_RESPECTFUL)) { + device = getDeviceForStrategy(STRATEGY_SONIFICATION_RESPECTFUL, fromCache); + } else if (outputDesc->isStrategyActive(STRATEGY_MEDIA)) { + device = getDeviceForStrategy(STRATEGY_MEDIA, fromCache); + } else if (outputDesc->isStrategyActive(STRATEGY_DTMF)) { + device = getDeviceForStrategy(STRATEGY_DTMF, fromCache); + } + + int direct_in_use=0; + for (size_t i = 0; i < mOutputs.size(); i++) { + sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i); + if (desc->mFlags & AUDIO_OUTPUT_FLAG_DIRECT) + direct_in_use=1; + } + + audio_devices_t availableOutputDeviceTypes = mAvailableOutputDevices.types(); + ALOGV("[%s %d]outputDesc->mDevice/0x%x device/%x direct_in_use/%d availableOutputDeviceTypes/0x%x isStrategyActive(STRATEGY_MEDIA)/%d fromCache/%d\n", __FUNCTION__,__LINE__, + outputDesc->mDevice,device,direct_in_use,availableOutputDeviceTypes,outputDesc->isStrategyActive(STRATEGY_MEDIA),fromCache); + if (outputDesc->mDevice == AUDIO_DEVICE_OUT_SPEAKER && outputDesc->isStrategyActive(STRATEGY_MEDIA) && (device == AUDIO_DEVICE_OUT_AUX_DIGITAL && !get_codec_type("/sys/class/audiodsp/digital_codec")) || direct_in_use) + { + device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_SPEAKER; + if (device == AUDIO_DEVICE_NONE) + device = AUDIO_DEVICE_OUT_AUX_DIGITAL; + if (device == AUDIO_DEVICE_OUT_SPEAKER) + { + ALOGV("[%s %d]direct_in_use/%d force change device from %x to %x\n",__FUNCTION__,__LINE__, + direct_in_use,AUDIO_DEVICE_OUT_AUX_DIGITAL,AUDIO_DEVICE_OUT_SPEAKER); + } + } + ALOGV("[%s %d]selected device %x", __FUNCTION__,__LINE__,device); + return device; +} uint32_t DLGAudioPolicyManager::AudioPort::pickSamplingRate() const { diff --git a/DLGAudioPolicyManager.h b/DLGAudioPolicyManager.h index eddbc22..125b8d3 100644 --- a/DLGAudioPolicyManager.h +++ b/DLGAudioPolicyManager.h @@ -65,6 +65,7 @@ protected: audio_io_handle_t output, audio_devices_t device); audio_devices_t getDevicesForStream(audio_stream_type_t stream); + audio_devices_t getNewOutputDevice(audio_io_handle_t output, bool fromCache); private: // Flag which indicates whether to record from the submix device. bool mForceSubmixInputSelection; |