diff options
| author | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-12-06 03:16:05 +0000 |
|---|---|---|
| committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-12-06 04:21:20 +0000 |
| commit | 03b1fa7e0ebcebcc5ffcb780d88ab850f02a97c8 (patch) | |
| tree | 7f3f36df6d82d9d18c00ee1a7cd76a1d254a1ff6 | |
| parent | d0cf2604e13dc9b98cf4d7ec4226c8ae9a70c1b6 (diff) | |
| parent | 18fc094c0ed41851be3d746423c6695dd28d48e1 (diff) | |
| download | android_hardware_libhardware_legacy-03b1fa7e0ebcebcc5ffcb780d88ab850f02a97c8.tar.gz android_hardware_libhardware_legacy-03b1fa7e0ebcebcc5ffcb780d88ab850f02a97c8.tar.bz2 android_hardware_libhardware_legacy-03b1fa7e0ebcebcc5ffcb780d88ab850f02a97c8.zip | |
Merge tag 'android-4.4.1_r1' into HEAD
Android 4.4.1 Release 1
Conflicts:
audio/AudioPolicyManagerBase.cpp
Change-Id: I89ac037649e05540e85f7497e416f85032210776
| -rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 79 | ||||
| -rw-r--r-- | include/hardware_legacy/AudioPolicyManagerBase.h | 7 | ||||
| -rw-r--r-- | include/hardware_legacy/audio_policy_conf.h | 1 |
3 files changed, 79 insertions, 8 deletions
diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index e974aeb..6799b3b 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -585,12 +585,19 @@ audio_io_handle_t AudioPolicyManagerBase::getOutput(AudioSystem::stream_type str flags = (AudioSystem::output_flags)(flags | AUDIO_OUTPUT_FLAG_DIRECT); } - if (flags & AUDIO_OUTPUT_FLAG_DIRECT) { + // Do not allow offloading if one non offloadable effect is enabled. This prevents from + // creating an offloaded track and tearing it down immediately after start when audioflinger + // detects there is an active non offloadable effect. + // FIXME: We should check the audio session here but we do not have it in this context. + // This may prevent offloading in rare situations where effects are left active by apps + // in the background. + if (((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0) || + !isNonOffloadableEffectEnabled()) { profile = getProfileForDirectOutput(device, - samplingRate, - format, - channelMask, - (audio_output_flags_t)flags); + samplingRate, + format, + channelMask, + (audio_output_flags_t)flags); } if (profile != NULL) { @@ -1312,6 +1319,20 @@ status_t AudioPolicyManagerBase::setEffectEnabled(EffectDescriptor *pDesc, bool return NO_ERROR; } +bool AudioPolicyManagerBase::isNonOffloadableEffectEnabled() +{ + for (size_t i = 0; i < mEffects.size(); i++) { + const EffectDescriptor * const pDesc = mEffects.valueAt(i); + if (pDesc->mEnabled && (pDesc->mStrategy == STRATEGY_MEDIA) && + ((pDesc->mDesc.flags & EFFECT_FLAG_OFFLOAD_SUPPORTED) == 0)) { + ALOGV("isNonOffloadableEffectEnabled() non offloadable effect %s enabled on session %d", + pDesc->mDesc.name, pDesc->mSession); + return true; + } + } + return false; +} + bool AudioPolicyManagerBase::isStreamActive(int stream, uint32_t inPastMs) const { nsecs_t sysTime = systemTime(); @@ -1492,6 +1513,16 @@ bool AudioPolicyManagerBase::isOffloadSupported(const audio_offload_info_t& offl return false; } + // Do not allow offloading if one non offloadable effect is enabled. This prevents from + // creating an offloaded track and tearing it down immediately after start when audioflinger + // detects there is an active non offloadable effect. + // FIXME: We should check the audio session here but we do not have it in this context. + // This may prevent offloading in rare situations where effects are left active by apps + // in the background. + if (isNonOffloadableEffectEnabled()) { + return false; + } + // See if there is a profile to support this. // AUDIO_DEVICE_NONE IOProfile *profile = getProfileForDirectOutput(AUDIO_DEVICE_NONE /*ignore device */, @@ -1517,7 +1548,8 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien mPhoneState(AudioSystem::MODE_NORMAL), mLimitRingtoneVolume(false), mLastVoiceVolume(-1.0f), mTotalEffectsCpuLoad(0), mTotalEffectsMemory(0), - mA2dpSuspended(false), mHasA2dp(false), mHasUsb(false), mHasRemoteSubmix(false) + mA2dpSuspended(false), mHasA2dp(false), mHasUsb(false), mHasRemoteSubmix(false), + mSpeakerDrcEnabled(false) { mpClientInterface = clientInterface; @@ -1525,8 +1557,6 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien mForceUse[i] = AudioSystem::FORCE_NONE; } - initializeVolumeCurves(); - mA2dpDeviceAddress = String8(""); mScoDeviceAddress = String8(""); mUsbCardAndDevice = String8(""); @@ -1538,6 +1568,9 @@ AudioPolicyManagerBase::AudioPolicyManagerBase(AudioPolicyClientInterface *clien } } + // must be done after reading the policy + initializeVolumeCurves(); + // open all output streams needed to access attached devices for (size_t i = 0; i < mHwModules.size(); i++) { mHwModules[i]->mHandle = mpClientInterface->loadHwModule(mHwModules[i]->mName); @@ -2862,6 +2895,11 @@ const AudioPolicyManagerBase::VolumeCurvePoint {1, -29.7f}, {33, -20.1f}, {66, -10.2f}, {100, 0.0f} }; +const AudioPolicyManagerBase::VolumeCurvePoint + AudioPolicyManagerBase::sSpeakerSonificationVolumeCurveDrc[AudioPolicyManagerBase::VOLCNT] = { + {1, -35.7f}, {33, -26.1f}, {66, -13.2f}, {100, 0.0f} +}; + // AUDIO_STREAM_SYSTEM, AUDIO_STREAM_ENFORCED_AUDIBLE and AUDIO_STREAM_DTMF volume tracks // AUDIO_STREAM_RING on phones and AUDIO_STREAM_MUSIC on tablets. // AUDIO_STREAM_DTMF tracks AUDIO_STREAM_VOICE_CALL while in call (See AudioService.java). @@ -2873,6 +2911,11 @@ const AudioPolicyManagerBase::VolumeCurvePoint }; const AudioPolicyManagerBase::VolumeCurvePoint + AudioPolicyManagerBase::sDefaultSystemVolumeCurveDrc[AudioPolicyManagerBase::VOLCNT] = { + {1, -34.0f}, {33, -24.0f}, {66, -15.0f}, {100, -6.0f} +}; + +const AudioPolicyManagerBase::VolumeCurvePoint AudioPolicyManagerBase::sHeadsetSystemVolumeCurve[AudioPolicyManagerBase::VOLCNT] = { {1, -30.0f}, {33, -26.0f}, {66, -22.0f}, {100, -18.0f} }; @@ -2957,6 +3000,18 @@ void AudioPolicyManagerBase::initializeVolumeCurves() sVolumeProfiles[i][j]; } } + + // Check availability of DRC on speaker path: if available, override some of the speaker curves + if (mSpeakerDrcEnabled) { + mStreams[AUDIO_STREAM_SYSTEM].mVolumeCurve[DEVICE_CATEGORY_SPEAKER] = + sDefaultSystemVolumeCurveDrc; + mStreams[AUDIO_STREAM_RING].mVolumeCurve[DEVICE_CATEGORY_SPEAKER] = + sSpeakerSonificationVolumeCurveDrc; + mStreams[AUDIO_STREAM_ALARM].mVolumeCurve[DEVICE_CATEGORY_SPEAKER] = + sSpeakerSonificationVolumeCurveDrc; + mStreams[AUDIO_STREAM_NOTIFICATION].mVolumeCurve[DEVICE_CATEGORY_SPEAKER] = + sSpeakerSonificationVolumeCurveDrc; + } } float AudioPolicyManagerBase::computeVolume(int stream, @@ -3746,6 +3801,11 @@ uint32_t AudioPolicyManagerBase::stringToEnum(const struct StringToEnum *table, return 0; } +bool AudioPolicyManagerBase::stringToBool(const char *value) +{ + return ((strcasecmp("true", value) == 0) || (strcmp("1", value) == 0)); +} + audio_output_flags_t AudioPolicyManagerBase::parseFlagNames(char *name) { uint32_t flag = 0; @@ -4051,6 +4111,9 @@ void AudioPolicyManagerBase::loadGlobalConfig(cnode *root) } else if (strcmp(ATTACHED_INPUT_DEVICES_TAG, node->name) == 0) { mAvailableInputDevices = parseDeviceNames((char *)node->value) & ~AUDIO_DEVICE_BIT_IN; ALOGV("loadGlobalConfig() mAvailableInputDevices %04x", mAvailableInputDevices); + } else if (strcmp(SPEAKER_DRC_ENABLED_TAG, node->name) == 0) { + mSpeakerDrcEnabled = stringToBool((char *)node->value); + ALOGV("loadGlobalConfig() mSpeakerDrcEnabled = %d", mSpeakerDrcEnabled); } node = node->next; } diff --git a/include/hardware_legacy/AudioPolicyManagerBase.h b/include/hardware_legacy/AudioPolicyManagerBase.h index 0de4055..1b6a226 100644 --- a/include/hardware_legacy/AudioPolicyManagerBase.h +++ b/include/hardware_legacy/AudioPolicyManagerBase.h @@ -238,7 +238,9 @@ protected: static const VolumeCurvePoint sSpeakerMediaVolumeCurve[AudioPolicyManagerBase::VOLCNT]; // volume curve for sonification strategy on speakers static const VolumeCurvePoint sSpeakerSonificationVolumeCurve[AudioPolicyManagerBase::VOLCNT]; + static const VolumeCurvePoint sSpeakerSonificationVolumeCurveDrc[AudioPolicyManagerBase::VOLCNT]; static const VolumeCurvePoint sDefaultSystemVolumeCurve[AudioPolicyManagerBase::VOLCNT]; + static const VolumeCurvePoint sDefaultSystemVolumeCurveDrc[AudioPolicyManagerBase::VOLCNT]; static const VolumeCurvePoint sHeadsetSystemVolumeCurve[AudioPolicyManagerBase::VOLCNT]; static const VolumeCurvePoint sDefaultVoiceVolumeCurve[AudioPolicyManagerBase::VOLCNT]; static const VolumeCurvePoint sSpeakerVoiceVolumeCurve[AudioPolicyManagerBase::VOLCNT]; @@ -493,12 +495,15 @@ protected: audio_io_handle_t selectOutputForEffects(const SortedVector<audio_io_handle_t>& outputs); + bool isNonOffloadableEffectEnabled(); + // // Audio policy configuration file parsing (audio_policy.conf) // static uint32_t stringToEnum(const struct StringToEnum *table, size_t size, const char *name); + static bool stringToBool(const char *value); static audio_output_flags_t parseFlagNames(char *name); static audio_devices_t parseDeviceNames(char *name); void loadSamplingRates(char *name, IOProfile *profile); @@ -552,6 +557,8 @@ protected: audio_devices_t mAttachedOutputDevices; // output devices always available on the platform audio_devices_t mDefaultOutputDevice; // output device selected by default at boot time // (must be in mAttachedOutputDevices) + bool mSpeakerDrcEnabled;// true on devices that use DRC on the DEVICE_CATEGORY_SPEAKER path + // to boost soft sounds, used to adjust volume curves accordingly Vector <HwModule *> mHwModules; diff --git a/include/hardware_legacy/audio_policy_conf.h b/include/hardware_legacy/audio_policy_conf.h index fa58c36..3ec2c94 100644 --- a/include/hardware_legacy/audio_policy_conf.h +++ b/include/hardware_legacy/audio_policy_conf.h @@ -34,6 +34,7 @@ #define ATTACHED_OUTPUT_DEVICES_TAG "attached_output_devices" #define DEFAULT_OUTPUT_DEVICE_TAG "default_output_device" #define ATTACHED_INPUT_DEVICES_TAG "attached_input_devices" +#define SPEAKER_DRC_ENABLED_TAG "speaker_drc_enabled" // hw modules descriptions #define AUDIO_HW_MODULE_TAG "audio_hw_modules" |
