Loading services/audioflinger/AudioFlinger.h +2 −2 Original line number Diff line number Diff line Loading @@ -132,6 +132,7 @@ // Classes that depend on IAf* interfaces but are not cross-dependent. #include "PatchCommandThread.h" #include "DeviceEffectManager.h" #include "MelReporter.h" namespace android { Loading Loading @@ -166,6 +167,7 @@ class AudioFlinger : public AudioFlingerServerAdapter::Delegate friend class Client; // removeClient_l(); friend class DeviceEffectManager; friend class DeviceEffectManagerCallback; friend class MelReporter; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. friend class DirectOutputThread; Loading Loading @@ -588,8 +590,6 @@ public: using TeePatches = std::vector<TeePatch>; private: #include "MelReporter.h" // Find io handle by session id. // Preference is given to an io handle with a matching effect chain to session id. // If none found, AUDIO_IO_HANDLE_NONE is returned. Loading services/audioflinger/MelReporter.cpp +16 −16 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ */ // #define LOG_NDEBUG 0 #define LOG_TAG "AudioFlinger::MelReporter" #define LOG_TAG "MelReporter" #include "AudioFlinger.h" Loading @@ -28,7 +28,7 @@ using aidl::android::hardware::audio::core::sounddose::ISoundDose; namespace android { bool AudioFlinger::MelReporter::activateHalSoundDoseComputation(const std::string& module, bool MelReporter::activateHalSoundDoseComputation(const std::string& module, const sp<DeviceHalInterface>& device) { if (mSoundDoseManager->forceUseFrameworkMel()) { ALOGD("%s: Forcing use of internal MEL computation.", __func__); Loading Loading @@ -63,7 +63,7 @@ bool AudioFlinger::MelReporter::activateHalSoundDoseComputation(const std::strin return true; } void AudioFlinger::MelReporter::activateInternalSoundDoseComputation() { void MelReporter::activateInternalSoundDoseComputation() { { std::lock_guard _l(mLock); if (!mUseHalSoundDoseInterface) { Loading @@ -76,11 +76,11 @@ void AudioFlinger::MelReporter::activateInternalSoundDoseComputation() { mSoundDoseManager->setHalSoundDoseInterface(nullptr); } void AudioFlinger::MelReporter::onFirstRef() { void MelReporter::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); } bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { bool MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return false; Loading @@ -104,7 +104,7 @@ bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t de } } void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, void MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, const std::vector<playback_track_metadata_v7_t>& metadataVec) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); Loading Loading @@ -140,7 +140,7 @@ void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHan } } void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, void MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, const IAfPatchPanel::Patch& patch) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); Loading Loading @@ -180,7 +180,7 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, } } void AudioFlinger::MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) void MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l { auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); Loading @@ -205,7 +205,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l } } void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { void MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; Loading @@ -231,26 +231,26 @@ void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) stopMelComputationForPatch_l(melPatch); } void AudioFlinger::MelReporter::onUpdateAudioPatch(audio_patch_handle_t oldHandle, void MelReporter::onUpdateAudioPatch(audio_patch_handle_t oldHandle, audio_patch_handle_t newHandle, const IAfPatchPanel::Patch& patch) { onReleaseAudioPatch(oldHandle); onCreateAudioPatch(newHandle, patch); } sp<media::ISoundDose> AudioFlinger::MelReporter::getSoundDoseInterface( sp<media::ISoundDose> MelReporter::getSoundDoseInterface( const sp<media::ISoundDoseCallback>& callback) { // no need to lock since getSoundDoseInterface is synchronized return mSoundDoseManager->getSoundDoseInterface(callback); } void AudioFlinger::MelReporter::stopInternalMelComputation() { void MelReporter::stopInternalMelComputation() { ALOGV("%s", __func__); std::lock_guard _l(mLock); mActiveMelPatches.clear(); mUseHalSoundDoseInterface = true; } void AudioFlinger::MelReporter::stopMelComputationForPatch_l(const ActiveMelPatch& patch) void MelReporter::stopMelComputationForPatch_l(const ActiveMelPatch& patch) NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l { if (!patch.csdActive) { Loading Loading @@ -278,7 +278,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l } std::optional<audio_patch_handle_t> AudioFlinger::MelReporter::activePatchStreamHandle_l( std::optional<audio_patch_handle_t> MelReporter::activePatchStreamHandle_l( audio_io_handle_t streamHandle) { for(const auto& patchIt : mActiveMelPatches) { if (patchIt.second.streamHandle == streamHandle) { Loading @@ -288,11 +288,11 @@ std::optional<audio_patch_handle_t> AudioFlinger::MelReporter::activePatchStream return std::nullopt; } bool AudioFlinger::MelReporter::useHalSoundDoseInterface_l() { bool MelReporter::useHalSoundDoseInterface_l() { return !mSoundDoseManager->forceUseFrameworkMel() & mUseHalSoundDoseInterface; } std::string AudioFlinger::MelReporter::dump() { std::string MelReporter::dump() { std::lock_guard _l(mLock); std::string output("\nSound Dose:\n"); output.append(mSoundDoseManager->dump()); Loading services/audioflinger/MelReporter.h +8 −8 Original line number Diff line number Diff line Loading @@ -15,14 +15,14 @@ ** limitations under the License. */ #ifndef INCLUDING_FROM_AUDIOFLINGER_H #error This header file should only be included from AudioFlinger.h #endif #pragma once #include <mutex> #include <sounddose/SoundDoseManager.h> #include <unordered_map> namespace android { constexpr static int kMaxTimestampDeltaInSec = 120; /** Loading Loading @@ -112,9 +112,9 @@ private: * Locking order AudioFlinger::mLock -> PatchCommandThread::mLock -> MelReporter::mLock. */ std::mutex mLock; std::unordered_map<audio_patch_handle_t, ActiveMelPatch> mActiveMelPatches GUARDED_BY(AudioFlinger::MelReporter::mLock); std::unordered_map<audio_port_handle_t, int> mActiveDevices GUARDED_BY(AudioFlinger::MelReporter::mLock); bool mUseHalSoundDoseInterface GUARDED_BY(AudioFlinger::MelReporter::mLock) = false; std::unordered_map<audio_patch_handle_t, ActiveMelPatch> mActiveMelPatches GUARDED_BY(mLock); std::unordered_map<audio_port_handle_t, int> mActiveDevices GUARDED_BY(mLock); bool mUseHalSoundDoseInterface GUARDED_BY(mLock) = false; }; } // namespace android Loading
services/audioflinger/AudioFlinger.h +2 −2 Original line number Diff line number Diff line Loading @@ -132,6 +132,7 @@ // Classes that depend on IAf* interfaces but are not cross-dependent. #include "PatchCommandThread.h" #include "DeviceEffectManager.h" #include "MelReporter.h" namespace android { Loading Loading @@ -166,6 +167,7 @@ class AudioFlinger : public AudioFlingerServerAdapter::Delegate friend class Client; // removeClient_l(); friend class DeviceEffectManager; friend class DeviceEffectManagerCallback; friend class MelReporter; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. friend class DirectOutputThread; Loading Loading @@ -588,8 +590,6 @@ public: using TeePatches = std::vector<TeePatch>; private: #include "MelReporter.h" // Find io handle by session id. // Preference is given to an io handle with a matching effect chain to session id. // If none found, AUDIO_IO_HANDLE_NONE is returned. Loading
services/audioflinger/MelReporter.cpp +16 −16 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ */ // #define LOG_NDEBUG 0 #define LOG_TAG "AudioFlinger::MelReporter" #define LOG_TAG "MelReporter" #include "AudioFlinger.h" Loading @@ -28,7 +28,7 @@ using aidl::android::hardware::audio::core::sounddose::ISoundDose; namespace android { bool AudioFlinger::MelReporter::activateHalSoundDoseComputation(const std::string& module, bool MelReporter::activateHalSoundDoseComputation(const std::string& module, const sp<DeviceHalInterface>& device) { if (mSoundDoseManager->forceUseFrameworkMel()) { ALOGD("%s: Forcing use of internal MEL computation.", __func__); Loading Loading @@ -63,7 +63,7 @@ bool AudioFlinger::MelReporter::activateHalSoundDoseComputation(const std::strin return true; } void AudioFlinger::MelReporter::activateInternalSoundDoseComputation() { void MelReporter::activateInternalSoundDoseComputation() { { std::lock_guard _l(mLock); if (!mUseHalSoundDoseInterface) { Loading @@ -76,11 +76,11 @@ void AudioFlinger::MelReporter::activateInternalSoundDoseComputation() { mSoundDoseManager->setHalSoundDoseInterface(nullptr); } void AudioFlinger::MelReporter::onFirstRef() { void MelReporter::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); } bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { bool MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return false; Loading @@ -104,7 +104,7 @@ bool AudioFlinger::MelReporter::shouldComputeMelForDeviceType(audio_devices_t de } } void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, void MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, const std::vector<playback_track_metadata_v7_t>& metadataVec) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); Loading Loading @@ -140,7 +140,7 @@ void AudioFlinger::MelReporter::updateMetadataForCsd(audio_io_handle_t streamHan } } void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, void MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, const IAfPatchPanel::Patch& patch) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); Loading Loading @@ -180,7 +180,7 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, } } void AudioFlinger::MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) void MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l { auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); Loading @@ -205,7 +205,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l } } void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { void MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { if (!mSoundDoseManager->isCsdEnabled()) { ALOGV("%s csd is disabled", __func__); return; Loading @@ -231,26 +231,26 @@ void AudioFlinger::MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) stopMelComputationForPatch_l(melPatch); } void AudioFlinger::MelReporter::onUpdateAudioPatch(audio_patch_handle_t oldHandle, void MelReporter::onUpdateAudioPatch(audio_patch_handle_t oldHandle, audio_patch_handle_t newHandle, const IAfPatchPanel::Patch& patch) { onReleaseAudioPatch(oldHandle); onCreateAudioPatch(newHandle, patch); } sp<media::ISoundDose> AudioFlinger::MelReporter::getSoundDoseInterface( sp<media::ISoundDose> MelReporter::getSoundDoseInterface( const sp<media::ISoundDoseCallback>& callback) { // no need to lock since getSoundDoseInterface is synchronized return mSoundDoseManager->getSoundDoseInterface(callback); } void AudioFlinger::MelReporter::stopInternalMelComputation() { void MelReporter::stopInternalMelComputation() { ALOGV("%s", __func__); std::lock_guard _l(mLock); mActiveMelPatches.clear(); mUseHalSoundDoseInterface = true; } void AudioFlinger::MelReporter::stopMelComputationForPatch_l(const ActiveMelPatch& patch) void MelReporter::stopMelComputationForPatch_l(const ActiveMelPatch& patch) NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l { if (!patch.csdActive) { Loading Loading @@ -278,7 +278,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l } std::optional<audio_patch_handle_t> AudioFlinger::MelReporter::activePatchStreamHandle_l( std::optional<audio_patch_handle_t> MelReporter::activePatchStreamHandle_l( audio_io_handle_t streamHandle) { for(const auto& patchIt : mActiveMelPatches) { if (patchIt.second.streamHandle == streamHandle) { Loading @@ -288,11 +288,11 @@ std::optional<audio_patch_handle_t> AudioFlinger::MelReporter::activePatchStream return std::nullopt; } bool AudioFlinger::MelReporter::useHalSoundDoseInterface_l() { bool MelReporter::useHalSoundDoseInterface_l() { return !mSoundDoseManager->forceUseFrameworkMel() & mUseHalSoundDoseInterface; } std::string AudioFlinger::MelReporter::dump() { std::string MelReporter::dump() { std::lock_guard _l(mLock); std::string output("\nSound Dose:\n"); output.append(mSoundDoseManager->dump()); Loading
services/audioflinger/MelReporter.h +8 −8 Original line number Diff line number Diff line Loading @@ -15,14 +15,14 @@ ** limitations under the License. */ #ifndef INCLUDING_FROM_AUDIOFLINGER_H #error This header file should only be included from AudioFlinger.h #endif #pragma once #include <mutex> #include <sounddose/SoundDoseManager.h> #include <unordered_map> namespace android { constexpr static int kMaxTimestampDeltaInSec = 120; /** Loading Loading @@ -112,9 +112,9 @@ private: * Locking order AudioFlinger::mLock -> PatchCommandThread::mLock -> MelReporter::mLock. */ std::mutex mLock; std::unordered_map<audio_patch_handle_t, ActiveMelPatch> mActiveMelPatches GUARDED_BY(AudioFlinger::MelReporter::mLock); std::unordered_map<audio_port_handle_t, int> mActiveDevices GUARDED_BY(AudioFlinger::MelReporter::mLock); bool mUseHalSoundDoseInterface GUARDED_BY(AudioFlinger::MelReporter::mLock) = false; std::unordered_map<audio_patch_handle_t, ActiveMelPatch> mActiveMelPatches GUARDED_BY(mLock); std::unordered_map<audio_port_handle_t, int> mActiveDevices GUARDED_BY(mLock); bool mUseHalSoundDoseInterface GUARDED_BY(mLock) = false; }; } // namespace android