Loading services/audioflinger/AudioFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -329,7 +329,6 @@ AudioFlinger::AudioFlinger() mClientSharedHeapSize(kMinimumClientSharedHeapSizeBytes), mGlobalEffectEnableTime(0), mPatchCommandThread(sp<PatchCommandThread>::make()), mMelReporter(sp<MelReporter>::make(*this)), mSystemReady(false), mBluetoothLatencyModesEnabled(true) { Loading Loading @@ -412,6 +411,8 @@ void AudioFlinger::onFirstRef() mAAudioBurstsPerBuffer = getAAudioMixerBurstCountFromSystemProperty(); mAAudioHwBurstMinMicros = getAAudioHardwareBurstMinUsecFromSystemProperty(); } mMelReporter = sp<MelReporter>::make(sp<IAfMelReporterCallback>::fromExisting(this)); } status_t AudioFlinger::setAudioHalPids(const std::vector<pid_t>& pids) { Loading services/audioflinger/AudioFlinger.h +10 −3 Original line number Diff line number Diff line Loading @@ -165,10 +165,10 @@ class AudioFlinger : public AudioFlingerServerAdapter::Delegate // IAudioFlinger client interface , public IAfClientCallback , public IAfDeviceEffectManagerCallback , public IAfMelReporterCallback { friend class sp<AudioFlinger>; // TODO(b/291319167) Create interface and remove friends. friend class MelReporter; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. friend class DirectOutputThread; Loading Loading @@ -374,6 +374,7 @@ public: // ---- begin IAfDeviceEffectManagerCallback interface bool isAudioPolicyReady() const final { return mAudioPolicyReady.load(); } // below also used by IAfMelReporterCallback const sp<PatchCommandThread>& getPatchCommandThread() final { return mPatchCommandThread; } status_t addEffectToHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) final; Loading @@ -382,6 +383,13 @@ public: // ---- end of IAfDeviceEffectManagerCallback interface // ---- begin IAfMelReporterCallback interface Mutex& mutex() const final { return mLock; } sp<IAfThreadBase> checkOutputThread_l(audio_io_handle_t ioHandle) const final REQUIRES(mLock); // ---- end of IAfMelReporterCallback interface /* List available audio ports and their attributes */ status_t listAudioPorts(unsigned int* num_ports, struct audio_port* ports) const; Loading Loading @@ -619,7 +627,6 @@ private: } IAfThreadBase* checkThread_l(audio_io_handle_t ioHandle) const; sp<IAfThreadBase> checkOutputThread_l(audio_io_handle_t ioHandle) const REQUIRES(mLock); IAfPlaybackThread* checkPlaybackThread_l(audio_io_handle_t output) const; IAfPlaybackThread* checkMixerThread_l(audio_io_handle_t output) const; IAfRecordThread* checkRecordThread_l(audio_io_handle_t input) const; Loading Loading @@ -875,7 +882,7 @@ private: const sp<PatchCommandThread> mPatchCommandThread; /* const */ sp<DeviceEffectManager> mDeviceEffectManager; // set onFirstRef sp<MelReporter> mMelReporter; /* const */ sp<MelReporter> mMelReporter; // set onFirstRef bool mSystemReady; std::atomic_bool mAudioPolicyReady{}; Loading services/audioflinger/MelReporter.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ void MelReporter::activateInternalSoundDoseComputation() { } void MelReporter::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); mAfMelReporterCallback->getPatchCommandThread()->addListener(this); } bool MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { Loading Loading @@ -111,7 +111,7 @@ void MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, return; } std::lock_guard _laf(mAudioFlinger.mLock); std::lock_guard _laf(mAfMelReporterCallback->mutex()); std::lock_guard _l(mLock); auto activeMelPatchId = activePatchStreamHandle_l(streamHandle); if (!activeMelPatchId) { Loading Loading @@ -171,7 +171,7 @@ void MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, } if (!newPatch.deviceHandles.empty()) { std::lock_guard _afl(mAudioFlinger.mLock); std::lock_guard _afl(mAfMelReporterCallback->mutex()); std::lock_guard _l(mLock); ALOGV("%s add patch handle %d to active devices", __func__, handle); startMelComputationForActivePatch_l(newPatch); Loading @@ -183,7 +183,7 @@ void MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, void MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l { auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); auto outputThread = mAfMelReporterCallback->checkOutputThread_l(patch.streamHandle); if (outputThread == nullptr) { ALOGE("%s cannot find thread for stream handle %d", __func__, patch.streamHandle); return; Loading Loading @@ -226,7 +226,7 @@ void MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { mActiveMelPatches.erase(patchIt); } std::lock_guard _afl(mAudioFlinger.mLock); std::lock_guard _afl(mAfMelReporterCallback->mutex()); std::lock_guard _l(mLock); stopMelComputationForPatch_l(melPatch); } Loading @@ -252,7 +252,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l return; } auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); auto outputThread = mAfMelReporterCallback->checkOutputThread_l(patch.streamHandle); ALOGV("%s: stop MEL for stream id: %d", __func__, patch.streamHandle); for (const auto& deviceId : patch.deviceHandles) { Loading services/audioflinger/MelReporter.h +11 −4 Original line number Diff line number Diff line Loading @@ -25,14 +25,21 @@ namespace android { constexpr static int kMaxTimestampDeltaInSec = 120; class IAfMelReporterCallback : public virtual RefBase { public: virtual Mutex& mutex() const = 0; virtual const sp<PatchCommandThread>& getPatchCommandThread() = 0; virtual sp<IAfThreadBase> checkOutputThread_l(audio_io_handle_t ioHandle) const = 0; }; /** * Class for listening to new patches and starting the MEL computation. MelReporter is * concealed within AudioFlinger, their lifetimes are the same. */ class MelReporter : public PatchCommandThread::PatchCommandListener { public: explicit MelReporter(AudioFlinger& audioFlinger) : mAudioFlinger(audioFlinger), explicit MelReporter(const sp<IAfMelReporterCallback>& afMelReporterCallback) : mAfMelReporterCallback(afMelReporterCallback), mSoundDoseManager(sp<SoundDoseManager>::make()) {} void onFirstRef() override; Loading Loading @@ -100,7 +107,7 @@ private: bool useHalSoundDoseInterface_l() REQUIRES(mLock); AudioFlinger& mAudioFlinger; // does not own the object const sp<IAfMelReporterCallback> mAfMelReporterCallback; sp<SoundDoseManager> mSoundDoseManager; Loading Loading
services/audioflinger/AudioFlinger.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -329,7 +329,6 @@ AudioFlinger::AudioFlinger() mClientSharedHeapSize(kMinimumClientSharedHeapSizeBytes), mGlobalEffectEnableTime(0), mPatchCommandThread(sp<PatchCommandThread>::make()), mMelReporter(sp<MelReporter>::make(*this)), mSystemReady(false), mBluetoothLatencyModesEnabled(true) { Loading Loading @@ -412,6 +411,8 @@ void AudioFlinger::onFirstRef() mAAudioBurstsPerBuffer = getAAudioMixerBurstCountFromSystemProperty(); mAAudioHwBurstMinMicros = getAAudioHardwareBurstMinUsecFromSystemProperty(); } mMelReporter = sp<MelReporter>::make(sp<IAfMelReporterCallback>::fromExisting(this)); } status_t AudioFlinger::setAudioHalPids(const std::vector<pid_t>& pids) { Loading
services/audioflinger/AudioFlinger.h +10 −3 Original line number Diff line number Diff line Loading @@ -165,10 +165,10 @@ class AudioFlinger : public AudioFlingerServerAdapter::Delegate // IAudioFlinger client interface , public IAfClientCallback , public IAfDeviceEffectManagerCallback , public IAfMelReporterCallback { friend class sp<AudioFlinger>; // TODO(b/291319167) Create interface and remove friends. friend class MelReporter; friend class PatchPanel; // TODO(b/291012167) replace the Thread friends with an interface. friend class DirectOutputThread; Loading Loading @@ -374,6 +374,7 @@ public: // ---- begin IAfDeviceEffectManagerCallback interface bool isAudioPolicyReady() const final { return mAudioPolicyReady.load(); } // below also used by IAfMelReporterCallback const sp<PatchCommandThread>& getPatchCommandThread() final { return mPatchCommandThread; } status_t addEffectToHal( const struct audio_port_config* device, const sp<EffectHalInterface>& effect) final; Loading @@ -382,6 +383,13 @@ public: // ---- end of IAfDeviceEffectManagerCallback interface // ---- begin IAfMelReporterCallback interface Mutex& mutex() const final { return mLock; } sp<IAfThreadBase> checkOutputThread_l(audio_io_handle_t ioHandle) const final REQUIRES(mLock); // ---- end of IAfMelReporterCallback interface /* List available audio ports and their attributes */ status_t listAudioPorts(unsigned int* num_ports, struct audio_port* ports) const; Loading Loading @@ -619,7 +627,6 @@ private: } IAfThreadBase* checkThread_l(audio_io_handle_t ioHandle) const; sp<IAfThreadBase> checkOutputThread_l(audio_io_handle_t ioHandle) const REQUIRES(mLock); IAfPlaybackThread* checkPlaybackThread_l(audio_io_handle_t output) const; IAfPlaybackThread* checkMixerThread_l(audio_io_handle_t output) const; IAfRecordThread* checkRecordThread_l(audio_io_handle_t input) const; Loading Loading @@ -875,7 +882,7 @@ private: const sp<PatchCommandThread> mPatchCommandThread; /* const */ sp<DeviceEffectManager> mDeviceEffectManager; // set onFirstRef sp<MelReporter> mMelReporter; /* const */ sp<MelReporter> mMelReporter; // set onFirstRef bool mSystemReady; std::atomic_bool mAudioPolicyReady{}; Loading
services/audioflinger/MelReporter.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ void MelReporter::activateInternalSoundDoseComputation() { } void MelReporter::onFirstRef() { mAudioFlinger.mPatchCommandThread->addListener(this); mAfMelReporterCallback->getPatchCommandThread()->addListener(this); } bool MelReporter::shouldComputeMelForDeviceType(audio_devices_t device) { Loading Loading @@ -111,7 +111,7 @@ void MelReporter::updateMetadataForCsd(audio_io_handle_t streamHandle, return; } std::lock_guard _laf(mAudioFlinger.mLock); std::lock_guard _laf(mAfMelReporterCallback->mutex()); std::lock_guard _l(mLock); auto activeMelPatchId = activePatchStreamHandle_l(streamHandle); if (!activeMelPatchId) { Loading Loading @@ -171,7 +171,7 @@ void MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, } if (!newPatch.deviceHandles.empty()) { std::lock_guard _afl(mAudioFlinger.mLock); std::lock_guard _afl(mAfMelReporterCallback->mutex()); std::lock_guard _l(mLock); ALOGV("%s add patch handle %d to active devices", __func__, handle); startMelComputationForActivePatch_l(newPatch); Loading @@ -183,7 +183,7 @@ void MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, void MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l { auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); auto outputThread = mAfMelReporterCallback->checkOutputThread_l(patch.streamHandle); if (outputThread == nullptr) { ALOGE("%s cannot find thread for stream handle %d", __func__, patch.streamHandle); return; Loading Loading @@ -226,7 +226,7 @@ void MelReporter::onReleaseAudioPatch(audio_patch_handle_t handle) { mActiveMelPatches.erase(patchIt); } std::lock_guard _afl(mAudioFlinger.mLock); std::lock_guard _afl(mAfMelReporterCallback->mutex()); std::lock_guard _l(mLock); stopMelComputationForPatch_l(melPatch); } Loading @@ -252,7 +252,7 @@ NO_THREAD_SAFETY_ANALYSIS // access of AudioFlinger::checkOutputThread_l return; } auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); auto outputThread = mAfMelReporterCallback->checkOutputThread_l(patch.streamHandle); ALOGV("%s: stop MEL for stream id: %d", __func__, patch.streamHandle); for (const auto& deviceId : patch.deviceHandles) { Loading
services/audioflinger/MelReporter.h +11 −4 Original line number Diff line number Diff line Loading @@ -25,14 +25,21 @@ namespace android { constexpr static int kMaxTimestampDeltaInSec = 120; class IAfMelReporterCallback : public virtual RefBase { public: virtual Mutex& mutex() const = 0; virtual const sp<PatchCommandThread>& getPatchCommandThread() = 0; virtual sp<IAfThreadBase> checkOutputThread_l(audio_io_handle_t ioHandle) const = 0; }; /** * Class for listening to new patches and starting the MEL computation. MelReporter is * concealed within AudioFlinger, their lifetimes are the same. */ class MelReporter : public PatchCommandThread::PatchCommandListener { public: explicit MelReporter(AudioFlinger& audioFlinger) : mAudioFlinger(audioFlinger), explicit MelReporter(const sp<IAfMelReporterCallback>& afMelReporterCallback) : mAfMelReporterCallback(afMelReporterCallback), mSoundDoseManager(sp<SoundDoseManager>::make()) {} void onFirstRef() override; Loading Loading @@ -100,7 +107,7 @@ private: bool useHalSoundDoseInterface_l() REQUIRES(mLock); AudioFlinger& mAudioFlinger; // does not own the object const sp<IAfMelReporterCallback> mAfMelReporterCallback; sp<SoundDoseManager> mSoundDoseManager; Loading