Loading media/libaudioclient/aidl/android/media/ISoundDose.aidl +4 −6 Original line number Diff line number Diff line Loading @@ -49,13 +49,11 @@ interface ISoundDose { oneway void updateAttenuation(float attenuationDB, int device); /** * Disable the calculation of sound dose. This has the effect that no MEL * values will be computed on the framework side. The MEL returned from * the IHalSoundDoseCallbacks will be ignored. * Should only be called once at startup if the AudioService does not * support CSD. * Enables/disables the calculation of sound dose. This has the effect that * if disabled no MEL values will be computed on the framework side. The MEL * returned from the IHalSoundDoseCallbacks will be ignored. */ oneway void disableCsd(); oneway void setCsdEnabled(boolean enabled); /* -------------------------- Test API methods -------------------------- /** Get the currently used RS2 upper bound. */ Loading services/audioflinger/MelReporter.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ void AudioFlinger::MelReporter::onFirstRef() { } bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return false; } Loading @@ -107,7 +107,7 @@ bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t de void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, const std::vector<playback_track_metadata_v7_t>& metadataVec) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; } Loading Loading @@ -143,7 +143,7 @@ void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHan void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, const PatchPanel::Patch& patch) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; } Loading Loading @@ -207,7 +207,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l } void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; } Loading services/audioflinger/sounddose/SoundDoseManager.cpp +16 −15 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( size_t channelCount, audio_format_t format) { std::lock_guard _l(mLock); if (mHalSoundDose != nullptr && !mDisableCsd) { if (mHalSoundDose != nullptr && mEnabledCsd) { ALOGD("%s: using HAL MEL computation, no MelProcessor needed.", __func__); return nullptr; } Loading Loading @@ -290,11 +290,11 @@ binder::Status SoundDoseManager::SoundDose::updateAttenuation(float attenuationD return binder::Status::ok(); } binder::Status SoundDoseManager::SoundDose::disableCsd() { binder::Status SoundDoseManager::SoundDose::setCsdEnabled(bool enabled) { ALOGV("%s", __func__); auto soundDoseManager = mSoundDoseManager.promote(); if (soundDoseManager != nullptr) { soundDoseManager->disableCsd(); soundDoseManager->setCsdEnabled(enabled); } return binder::Status::ok(); } Loading Loading @@ -365,26 +365,27 @@ void SoundDoseManager::updateAttenuation(float attenuationDB, audio_devices_t de } } void SoundDoseManager::disableCsd() { void SoundDoseManager::setCsdEnabled(bool enabled) { ALOGV("%s", __func__); std::lock_guard _l(mLock); mDisableCsd = true; mEnabledCsd = enabled; // Normally, there should be no active MelProcessors when this method is called // We pause however every cached MelProcessor as a defensive mechanism to not // have unnecessary processing for (auto& activeEntry : mActiveProcessors) { auto melProcessor = activeEntry.second.promote(); if (melProcessor != nullptr) { if (enabled) { melProcessor->resume(); } else { melProcessor->pause(); } } } } bool SoundDoseManager::isCsdDisabled() { bool SoundDoseManager::isCsdEnabled() { std::lock_guard _l(mLock); return mDisableCsd; return mEnabledCsd; } void SoundDoseManager::setUseFrameworkMel(bool useFrameworkMel) { Loading @@ -411,7 +412,7 @@ bool SoundDoseManager::forceComputeCsdOnAllDevices() const { } bool SoundDoseManager::isSoundDoseHalSupported() const { if (mDisableCsd) { if (!mEnabledCsd) { return false; } Loading Loading @@ -455,7 +456,7 @@ void SoundDoseManager::onNewMelValues(const std::vector<float>& mels, size_t off float currentCsd; { std::lock_guard _l(mLock); if (mDisableCsd) { if (!mEnabledCsd) { return; } Loading Loading @@ -496,7 +497,7 @@ void SoundDoseManager::onMomentaryExposure(float currentMel, audio_port_handle_t { std::lock_guard _l(mLock); if (mDisableCsd) { if (!mEnabledCsd) { return; } } Loading @@ -522,7 +523,7 @@ std::string SoundDoseManager::dump() const { std::string output; { std::lock_guard _l(mLock); if (mDisableCsd) { if (!mEnabledCsd) { base::StringAppendF(&output, "CSD is disabled"); return output; } Loading services/audioflinger/sounddose/SoundDoseManager.h +5 −5 Original line number Diff line number Diff line Loading @@ -101,8 +101,8 @@ public: /** Clear all map entries with passed audio_port_handle_t. */ void clearMapDeviceIdEntries(audio_port_handle_t deviceId); /** Returns true if CSD is disabled. */ bool isCsdDisabled(); /** Returns true if CSD is enabled. */ bool isCsdEnabled(); std::string dump() const; Loading Loading @@ -137,7 +137,7 @@ private: const std::vector<media::SoundDoseRecord>& records) override; binder::Status updateAttenuation(float attenuationDB, int device) override; binder::Status getOutputRs2UpperBound(float* value) override; binder::Status disableCsd() override; binder::Status setCsdEnabled(bool enabled) override; binder::Status getCsd(float* value) override; binder::Status forceUseFrameworkMel(bool useFrameworkMel) override; Loading Loading @@ -170,7 +170,7 @@ private: sp<media::ISoundDoseCallback> getSoundDoseCallback() const; void updateAttenuation(float attenuationDB, audio_devices_t deviceType); void disableCsd(); void setCsdEnabled(bool enabled); void setUseFrameworkMel(bool useFrameworkMel); void setComputeCsdOnAllDevices(bool computeCsdOnAllDevices); bool isSoundDoseHalSupported() const; Loading Loading @@ -202,7 +202,7 @@ private: bool mUseFrameworkMel GUARDED_BY(mLock) = true; bool mComputeCsdOnAllDevices GUARDED_BY(mLock) = false; bool mDisableCsd GUARDED_BY(mLock) = false; bool mEnabledCsd GUARDED_BY(mLock) = true; }; } // namespace android Loading
media/libaudioclient/aidl/android/media/ISoundDose.aidl +4 −6 Original line number Diff line number Diff line Loading @@ -49,13 +49,11 @@ interface ISoundDose { oneway void updateAttenuation(float attenuationDB, int device); /** * Disable the calculation of sound dose. This has the effect that no MEL * values will be computed on the framework side. The MEL returned from * the IHalSoundDoseCallbacks will be ignored. * Should only be called once at startup if the AudioService does not * support CSD. * Enables/disables the calculation of sound dose. This has the effect that * if disabled no MEL values will be computed on the framework side. The MEL * returned from the IHalSoundDoseCallbacks will be ignored. */ oneway void disableCsd(); oneway void setCsdEnabled(boolean enabled); /* -------------------------- Test API methods -------------------------- /** Get the currently used RS2 upper bound. */ Loading
services/audioflinger/MelReporter.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ void AudioFlinger::MelReporter::onFirstRef() { } bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return false; } Loading @@ -107,7 +107,7 @@ bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t de void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, const std::vector<playback_track_metadata_v7_t>& metadataVec) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; } Loading Loading @@ -143,7 +143,7 @@ void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHan void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, const PatchPanel::Patch& patch) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; } Loading Loading @@ -207,7 +207,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l } void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { if (mSoundDoseManager->isCsdDisabled()) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; } Loading
services/audioflinger/sounddose/SoundDoseManager.cpp +16 −15 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( size_t channelCount, audio_format_t format) { std::lock_guard _l(mLock); if (mHalSoundDose != nullptr && !mDisableCsd) { if (mHalSoundDose != nullptr && mEnabledCsd) { ALOGD("%s: using HAL MEL computation, no MelProcessor needed.", __func__); return nullptr; } Loading Loading @@ -290,11 +290,11 @@ binder::Status SoundDoseManager::SoundDose::updateAttenuation(float attenuationD return binder::Status::ok(); } binder::Status SoundDoseManager::SoundDose::disableCsd() { binder::Status SoundDoseManager::SoundDose::setCsdEnabled(bool enabled) { ALOGV("%s", __func__); auto soundDoseManager = mSoundDoseManager.promote(); if (soundDoseManager != nullptr) { soundDoseManager->disableCsd(); soundDoseManager->setCsdEnabled(enabled); } return binder::Status::ok(); } Loading Loading @@ -365,26 +365,27 @@ void SoundDoseManager::updateAttenuation(float attenuationDB, audio_devices_t de } } void SoundDoseManager::disableCsd() { void SoundDoseManager::setCsdEnabled(bool enabled) { ALOGV("%s", __func__); std::lock_guard _l(mLock); mDisableCsd = true; mEnabledCsd = enabled; // Normally, there should be no active MelProcessors when this method is called // We pause however every cached MelProcessor as a defensive mechanism to not // have unnecessary processing for (auto& activeEntry : mActiveProcessors) { auto melProcessor = activeEntry.second.promote(); if (melProcessor != nullptr) { if (enabled) { melProcessor->resume(); } else { melProcessor->pause(); } } } } bool SoundDoseManager::isCsdDisabled() { bool SoundDoseManager::isCsdEnabled() { std::lock_guard _l(mLock); return mDisableCsd; return mEnabledCsd; } void SoundDoseManager::setUseFrameworkMel(bool useFrameworkMel) { Loading @@ -411,7 +412,7 @@ bool SoundDoseManager::forceComputeCsdOnAllDevices() const { } bool SoundDoseManager::isSoundDoseHalSupported() const { if (mDisableCsd) { if (!mEnabledCsd) { return false; } Loading Loading @@ -455,7 +456,7 @@ void SoundDoseManager::onNewMelValues(const std::vector<float>& mels, size_t off float currentCsd; { std::lock_guard _l(mLock); if (mDisableCsd) { if (!mEnabledCsd) { return; } Loading Loading @@ -496,7 +497,7 @@ void SoundDoseManager::onMomentaryExposure(float currentMel, audio_port_handle_t { std::lock_guard _l(mLock); if (mDisableCsd) { if (!mEnabledCsd) { return; } } Loading @@ -522,7 +523,7 @@ std::string SoundDoseManager::dump() const { std::string output; { std::lock_guard _l(mLock); if (mDisableCsd) { if (!mEnabledCsd) { base::StringAppendF(&output, "CSD is disabled"); return output; } Loading
services/audioflinger/sounddose/SoundDoseManager.h +5 −5 Original line number Diff line number Diff line Loading @@ -101,8 +101,8 @@ public: /** Clear all map entries with passed audio_port_handle_t. */ void clearMapDeviceIdEntries(audio_port_handle_t deviceId); /** Returns true if CSD is disabled. */ bool isCsdDisabled(); /** Returns true if CSD is enabled. */ bool isCsdEnabled(); std::string dump() const; Loading Loading @@ -137,7 +137,7 @@ private: const std::vector<media::SoundDoseRecord>& records) override; binder::Status updateAttenuation(float attenuationDB, int device) override; binder::Status getOutputRs2UpperBound(float* value) override; binder::Status disableCsd() override; binder::Status setCsdEnabled(bool enabled) override; binder::Status getCsd(float* value) override; binder::Status forceUseFrameworkMel(bool useFrameworkMel) override; Loading Loading @@ -170,7 +170,7 @@ private: sp<media::ISoundDoseCallback> getSoundDoseCallback() const; void updateAttenuation(float attenuationDB, audio_devices_t deviceType); void disableCsd(); void setCsdEnabled(bool enabled); void setUseFrameworkMel(bool useFrameworkMel); void setComputeCsdOnAllDevices(bool computeCsdOnAllDevices); bool isSoundDoseHalSupported() const; Loading Loading @@ -202,7 +202,7 @@ private: bool mUseFrameworkMel GUARDED_BY(mLock) = true; bool mComputeCsdOnAllDevices GUARDED_BY(mLock) = false; bool mDisableCsd GUARDED_BY(mLock) = false; bool mEnabledCsd GUARDED_BY(mLock) = true; }; } // namespace android