Loading media/libnbaio/AudioStreamOutSink.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -103,19 +103,24 @@ status_t AudioStreamOutSink::getTimestamp(ExtendedTimestamp ×tamp) void AudioStreamOutSink::startMelComputation(const sp<audio_utils::MelProcessor>& processor) { ALOGV("%s start mel computation for device %d", __func__, processor->getDeviceId()); mMelProcessor = processor; // update format for MEL computation mMelProcessor.store(processor); if (processor) { processor->updateAudioFormat(mFormat.mSampleRate, mFormat.mChannelCount, mFormat.mFormat); // update format for MEL computation processor->updateAudioFormat(mFormat.mSampleRate, mFormat.mChannelCount, mFormat.mFormat); processor->resume(); } } void AudioStreamOutSink::stopMelComputation() { auto melProcessor = mMelProcessor.load(); if (melProcessor != nullptr) { ALOGV("%s stop mel computation for device %d", __func__, melProcessor->getDeviceId()); mMelProcessor = nullptr; ALOGV("%s pause mel computation for device %d", __func__, melProcessor->getDeviceId()); melProcessor->pause(); } } Loading services/audioflinger/MelReporter.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -174,6 +174,7 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, } } if (!newPatch.deviceHandles.empty()) { std::lock_guard _afl(mAudioFlinger.mLock); std::lock_guard _l(mLock); ALOGV("%s add patch handle %d to active devices", __func__, handle); Loading @@ -181,6 +182,7 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, newPatch.csdActive = true; mActiveMelPatches[handle] = newPatch; } } void AudioFlinger::MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) { auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); Loading Loading @@ -264,7 +266,6 @@ void AudioFlinger::MelReporter::stopMelComputationForPatch_l(const ActiveMelPatc } } mSoundDoseManager->removeStreamProcessor(patch.streamHandle); if (outputThread != nullptr) { outputThread->stopMelComputation_l(); } Loading services/audioflinger/Threads.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -10858,16 +10858,23 @@ void AudioFlinger::MmapPlaybackThread::startMelComputation_l( const sp<audio_utils::MelProcessor>& processor) { ALOGV("%s: starting mel processor for thread %d", __func__, id()); if (processor != nullptr) { mMelProcessor = processor; mMelProcessor.store(processor); if (processor) { processor->resume(); } // no need to update output format for MMapPlaybackThread since it is // assigned constant for each thread } // stopMelComputation_l() must be called with AudioFlinger::mLock held void AudioFlinger::MmapPlaybackThread::stopMelComputation_l() { ALOGV("%s: stopping mel processor for thread %d", __func__, id()); mMelProcessor = nullptr; ALOGV("%s: pausing mel processor for thread %d", __func__, id()); auto melProcessor = mMelProcessor.load(); if (melProcessor != nullptr) { melProcessor->pause(); } } void AudioFlinger::MmapPlaybackThread::dumpInternals_l(int fd, const Vector<String16>& args) Loading services/audioflinger/sounddose/SoundDoseManager.cpp +24 −21 Original line number Diff line number Diff line Loading @@ -51,14 +51,16 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( std::lock_guard _l(mLock); if (mHalSoundDose != nullptr && !mDisableCsd) { ALOGW("%s: using HAL MEL computation, no MelProcessor needed.", __func__); ALOGD("%s: using HAL MEL computation, no MelProcessor needed.", __func__); return nullptr; } auto streamProcessor = mActiveProcessors.find(streamHandle); sp<audio_utils::MelProcessor> processor; if (streamProcessor != mActiveProcessors.end() && (processor = streamProcessor->second.promote())) { if (streamProcessor != mActiveProcessors.end()) { auto processor = streamProcessor->second.promote(); // if processor is nullptr it means it was removed by the playback // thread and can be replaced in the mActiveProcessors map if (processor != nullptr) { ALOGV("%s: found callback for stream id %d", __func__, streamHandle); const auto activeTypeIt = mActiveDeviceTypes.find(deviceId); if (activeTypeIt != mActiveDeviceTypes.end()) { Loading @@ -67,7 +69,9 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( processor->setDeviceId(deviceId); processor->setOutputRs2UpperBound(mRs2UpperBound); return processor; } else { } } ALOGV("%s: creating new callback for stream id %d", __func__, streamHandle); sp<audio_utils::MelProcessor> melProcessor = sp<audio_utils::MelProcessor>::make( sampleRate, channelCount, format, this, deviceId, mRs2UpperBound); Loading @@ -78,7 +82,6 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( mActiveProcessors[streamHandle] = melProcessor; return melProcessor; } } bool SoundDoseManager::setHalSoundDoseInterface(const std::shared_ptr<ISoundDose>& halSoundDose) { ALOGV("%s", __func__); Loading Loading
media/libnbaio/AudioStreamOutSink.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -103,19 +103,24 @@ status_t AudioStreamOutSink::getTimestamp(ExtendedTimestamp ×tamp) void AudioStreamOutSink::startMelComputation(const sp<audio_utils::MelProcessor>& processor) { ALOGV("%s start mel computation for device %d", __func__, processor->getDeviceId()); mMelProcessor = processor; // update format for MEL computation mMelProcessor.store(processor); if (processor) { processor->updateAudioFormat(mFormat.mSampleRate, mFormat.mChannelCount, mFormat.mFormat); // update format for MEL computation processor->updateAudioFormat(mFormat.mSampleRate, mFormat.mChannelCount, mFormat.mFormat); processor->resume(); } } void AudioStreamOutSink::stopMelComputation() { auto melProcessor = mMelProcessor.load(); if (melProcessor != nullptr) { ALOGV("%s stop mel computation for device %d", __func__, melProcessor->getDeviceId()); mMelProcessor = nullptr; ALOGV("%s pause mel computation for device %d", __func__, melProcessor->getDeviceId()); melProcessor->pause(); } } Loading
services/audioflinger/MelReporter.cpp +9 −8 Original line number Diff line number Diff line Loading @@ -174,6 +174,7 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, } } if (!newPatch.deviceHandles.empty()) { std::lock_guard _afl(mAudioFlinger.mLock); std::lock_guard _l(mLock); ALOGV("%s add patch handle %d to active devices", __func__, handle); Loading @@ -181,6 +182,7 @@ void AudioFlinger::MelReporter::onCreateAudioPatch(audio_patch_handle_t handle, newPatch.csdActive = true; mActiveMelPatches[handle] = newPatch; } } void AudioFlinger::MelReporter::startMelComputationForActivePatch_l(const ActiveMelPatch& patch) { auto outputThread = mAudioFlinger.checkOutputThread_l(patch.streamHandle); Loading Loading @@ -264,7 +266,6 @@ void AudioFlinger::MelReporter::stopMelComputationForPatch_l(const ActiveMelPatc } } mSoundDoseManager->removeStreamProcessor(patch.streamHandle); if (outputThread != nullptr) { outputThread->stopMelComputation_l(); } Loading
services/audioflinger/Threads.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -10858,16 +10858,23 @@ void AudioFlinger::MmapPlaybackThread::startMelComputation_l( const sp<audio_utils::MelProcessor>& processor) { ALOGV("%s: starting mel processor for thread %d", __func__, id()); if (processor != nullptr) { mMelProcessor = processor; mMelProcessor.store(processor); if (processor) { processor->resume(); } // no need to update output format for MMapPlaybackThread since it is // assigned constant for each thread } // stopMelComputation_l() must be called with AudioFlinger::mLock held void AudioFlinger::MmapPlaybackThread::stopMelComputation_l() { ALOGV("%s: stopping mel processor for thread %d", __func__, id()); mMelProcessor = nullptr; ALOGV("%s: pausing mel processor for thread %d", __func__, id()); auto melProcessor = mMelProcessor.load(); if (melProcessor != nullptr) { melProcessor->pause(); } } void AudioFlinger::MmapPlaybackThread::dumpInternals_l(int fd, const Vector<String16>& args) Loading
services/audioflinger/sounddose/SoundDoseManager.cpp +24 −21 Original line number Diff line number Diff line Loading @@ -51,14 +51,16 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( std::lock_guard _l(mLock); if (mHalSoundDose != nullptr && !mDisableCsd) { ALOGW("%s: using HAL MEL computation, no MelProcessor needed.", __func__); ALOGD("%s: using HAL MEL computation, no MelProcessor needed.", __func__); return nullptr; } auto streamProcessor = mActiveProcessors.find(streamHandle); sp<audio_utils::MelProcessor> processor; if (streamProcessor != mActiveProcessors.end() && (processor = streamProcessor->second.promote())) { if (streamProcessor != mActiveProcessors.end()) { auto processor = streamProcessor->second.promote(); // if processor is nullptr it means it was removed by the playback // thread and can be replaced in the mActiveProcessors map if (processor != nullptr) { ALOGV("%s: found callback for stream id %d", __func__, streamHandle); const auto activeTypeIt = mActiveDeviceTypes.find(deviceId); if (activeTypeIt != mActiveDeviceTypes.end()) { Loading @@ -67,7 +69,9 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( processor->setDeviceId(deviceId); processor->setOutputRs2UpperBound(mRs2UpperBound); return processor; } else { } } ALOGV("%s: creating new callback for stream id %d", __func__, streamHandle); sp<audio_utils::MelProcessor> melProcessor = sp<audio_utils::MelProcessor>::make( sampleRate, channelCount, format, this, deviceId, mRs2UpperBound); Loading @@ -78,7 +82,6 @@ sp<audio_utils::MelProcessor> SoundDoseManager::getOrCreateProcessorForDevice( mActiveProcessors[streamHandle] = melProcessor; return melProcessor; } } bool SoundDoseManager::setHalSoundDoseInterface(const std::shared_ptr<ISoundDose>& halSoundDose) { ALOGV("%s", __func__); Loading