Loading services/audioflinger/AudioFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -311,7 +311,8 @@ void AudioFlinger::onFirstRef() } mPatchPanel = IAfPatchPanel::create(sp<IAfPatchPanelCallback>::fromExisting(this)); mMelReporter = sp<MelReporter>::make(sp<IAfMelReporterCallback>::fromExisting(this)); mMelReporter = sp<MelReporter>::make(sp<IAfMelReporterCallback>::fromExisting(this), mPatchPanel); } status_t AudioFlinger::setAudioHalPids(const std::vector<pid_t>& pids) { Loading services/audioflinger/MelReporter.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,22 @@ void MelReporter::stopMelComputationForDeviceId(audio_port_handle_t deviceId) { } void MelReporter::applyAllAudioPatches() { ALOGV("%s", __func__); std::vector<IAfPatchPanel::Patch> patchesCopy; { audio_utils::lock_guard _laf(mAfMelReporterCallback->mutex()); for (const auto& patch : mAfPatchPanel->patches_l()) { patchesCopy.emplace_back(patch.second); } } for (const auto& patch : patchesCopy) { onCreateAudioPatch(patch.mHalHandle, patch); } } std::optional<audio_patch_handle_t> MelReporter::activePatchStreamHandle_l( audio_io_handle_t streamHandle) { for(const auto& patchIt : mActiveMelPatches) { Loading services/audioflinger/MelReporter.h +8 −6 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ namespace android { constexpr static int kMaxTimestampDeltaInSec = 120; class IAfMelReporterCallback : public virtual RefBase { public: virtual audio_utils::mutex& mutex() const Loading @@ -45,8 +43,10 @@ public: class MelReporter : public PatchCommandThread::PatchCommandListener, public IMelReporterCallback { public: explicit MelReporter(const sp<IAfMelReporterCallback>& afMelReporterCallback) : mAfMelReporterCallback(afMelReporterCallback) {} MelReporter(const sp<IAfMelReporterCallback>& afMelReporterCallback, const sp<IAfPatchPanel>& afPatchPanel) : mAfMelReporterCallback(afMelReporterCallback), mAfPatchPanel(afPatchPanel) {} void onFirstRef() override; Loading Loading @@ -80,9 +80,10 @@ public: // IMelReporterCallback methods void stopMelComputationForDeviceId(audio_port_handle_t deviceId) final EXCLUDES_MelReporter_Mutex; EXCLUDES_AudioFlinger_Mutex EXCLUDES_MelReporter_Mutex; void startMelComputationForDeviceId(audio_port_handle_t deviceId) final EXCLUDES_MelReporter_Mutex; EXCLUDES_AudioFlinger_Mutex EXCLUDES_MelReporter_Mutex; void applyAllAudioPatches() final EXCLUDES_AudioFlinger_Mutex EXCLUDES_MelReporter_Mutex; // PatchCommandListener methods void onCreateAudioPatch(audio_patch_handle_t handle, Loading Loading @@ -131,6 +132,7 @@ private: bool useHalSoundDoseInterface_l() REQUIRES(mutex()); const sp<IAfMelReporterCallback> mAfMelReporterCallback; const sp<IAfPatchPanel> mAfPatchPanel; /* const */ sp<SoundDoseManager> mSoundDoseManager; // set onFirstRef Loading services/audioflinger/sounddose/SoundDoseManager.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -590,9 +590,20 @@ bool SoundDoseManager::isFrameworkMelForced() const { } void SoundDoseManager::setComputeCsdOnAllDevices(bool computeCsdOnAllDevices) { bool changed = false; { const std::lock_guard _l(mLock); if (mHalSoundDose.size() != 0) { // when using the HAL path we cannot enforce to deliver values for all devices changed = mUseFrameworkMel != computeCsdOnAllDevices; mUseFrameworkMel = computeCsdOnAllDevices; } mComputeCsdOnAllDevices = computeCsdOnAllDevices; } if (changed && computeCsdOnAllDevices) { mMelReporterCallback->applyAllAudioPatches(); } } bool SoundDoseManager::isComputeCsdForcedOnAllDevices() const { const std::lock_guard _l(mLock); Loading services/audioflinger/sounddose/SoundDoseManager.h +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ public: virtual void stopMelComputationForDeviceId(audio_port_handle_t deviceId) = 0; virtual void startMelComputationForDeviceId(audio_port_handle_t deviceId) = 0; virtual void applyAllAudioPatches() = 0; }; class SoundDoseManager : public audio_utils::MelProcessor::MelCallback { Loading Loading
services/audioflinger/AudioFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -311,7 +311,8 @@ void AudioFlinger::onFirstRef() } mPatchPanel = IAfPatchPanel::create(sp<IAfPatchPanelCallback>::fromExisting(this)); mMelReporter = sp<MelReporter>::make(sp<IAfMelReporterCallback>::fromExisting(this)); mMelReporter = sp<MelReporter>::make(sp<IAfMelReporterCallback>::fromExisting(this), mPatchPanel); } status_t AudioFlinger::setAudioHalPids(const std::vector<pid_t>& pids) { Loading
services/audioflinger/MelReporter.cpp +16 −0 Original line number Diff line number Diff line Loading @@ -307,6 +307,22 @@ void MelReporter::stopMelComputationForDeviceId(audio_port_handle_t deviceId) { } void MelReporter::applyAllAudioPatches() { ALOGV("%s", __func__); std::vector<IAfPatchPanel::Patch> patchesCopy; { audio_utils::lock_guard _laf(mAfMelReporterCallback->mutex()); for (const auto& patch : mAfPatchPanel->patches_l()) { patchesCopy.emplace_back(patch.second); } } for (const auto& patch : patchesCopy) { onCreateAudioPatch(patch.mHalHandle, patch); } } std::optional<audio_patch_handle_t> MelReporter::activePatchStreamHandle_l( audio_io_handle_t streamHandle) { for(const auto& patchIt : mActiveMelPatches) { Loading
services/audioflinger/MelReporter.h +8 −6 Original line number Diff line number Diff line Loading @@ -27,8 +27,6 @@ namespace android { constexpr static int kMaxTimestampDeltaInSec = 120; class IAfMelReporterCallback : public virtual RefBase { public: virtual audio_utils::mutex& mutex() const Loading @@ -45,8 +43,10 @@ public: class MelReporter : public PatchCommandThread::PatchCommandListener, public IMelReporterCallback { public: explicit MelReporter(const sp<IAfMelReporterCallback>& afMelReporterCallback) : mAfMelReporterCallback(afMelReporterCallback) {} MelReporter(const sp<IAfMelReporterCallback>& afMelReporterCallback, const sp<IAfPatchPanel>& afPatchPanel) : mAfMelReporterCallback(afMelReporterCallback), mAfPatchPanel(afPatchPanel) {} void onFirstRef() override; Loading Loading @@ -80,9 +80,10 @@ public: // IMelReporterCallback methods void stopMelComputationForDeviceId(audio_port_handle_t deviceId) final EXCLUDES_MelReporter_Mutex; EXCLUDES_AudioFlinger_Mutex EXCLUDES_MelReporter_Mutex; void startMelComputationForDeviceId(audio_port_handle_t deviceId) final EXCLUDES_MelReporter_Mutex; EXCLUDES_AudioFlinger_Mutex EXCLUDES_MelReporter_Mutex; void applyAllAudioPatches() final EXCLUDES_AudioFlinger_Mutex EXCLUDES_MelReporter_Mutex; // PatchCommandListener methods void onCreateAudioPatch(audio_patch_handle_t handle, Loading Loading @@ -131,6 +132,7 @@ private: bool useHalSoundDoseInterface_l() REQUIRES(mutex()); const sp<IAfMelReporterCallback> mAfMelReporterCallback; const sp<IAfPatchPanel> mAfPatchPanel; /* const */ sp<SoundDoseManager> mSoundDoseManager; // set onFirstRef Loading
services/audioflinger/sounddose/SoundDoseManager.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -590,9 +590,20 @@ bool SoundDoseManager::isFrameworkMelForced() const { } void SoundDoseManager::setComputeCsdOnAllDevices(bool computeCsdOnAllDevices) { bool changed = false; { const std::lock_guard _l(mLock); if (mHalSoundDose.size() != 0) { // when using the HAL path we cannot enforce to deliver values for all devices changed = mUseFrameworkMel != computeCsdOnAllDevices; mUseFrameworkMel = computeCsdOnAllDevices; } mComputeCsdOnAllDevices = computeCsdOnAllDevices; } if (changed && computeCsdOnAllDevices) { mMelReporterCallback->applyAllAudioPatches(); } } bool SoundDoseManager::isComputeCsdForcedOnAllDevices() const { const std::lock_guard _l(mLock); Loading
services/audioflinger/sounddose/SoundDoseManager.h +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ public: virtual void stopMelComputationForDeviceId(audio_port_handle_t deviceId) = 0; virtual void startMelComputationForDeviceId(audio_port_handle_t deviceId) = 0; virtual void applyAllAudioPatches() = 0; }; class SoundDoseManager : public audio_utils::MelProcessor::MelCallback { Loading