Loading services/audioflinger/MelReporter.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ namespace android { bool MelReporter::activateHalSoundDoseComputation(const std::string& module, const sp<DeviceHalInterface>& device) { if (mSoundDoseManager->forceUseFrameworkMel()) { if (mSoundDoseManager->isFrameworkMelForced()) { ALOGD("%s: Forcing use of internal MEL computation.", __func__); activateInternalSoundDoseComputation(); return false; Loading Loading @@ -318,7 +318,7 @@ std::optional<audio_patch_handle_t> MelReporter::activePatchStreamHandle_l( } bool MelReporter::useHalSoundDoseInterface_l() { return !mSoundDoseManager->forceUseFrameworkMel() & mUseHalSoundDoseInterface; return !mSoundDoseManager->isFrameworkMelForced() & mUseHalSoundDoseInterface; } std::string MelReporter::dump() { Loading services/audioflinger/sounddose/SoundDoseManager.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ using aidl::android::media::audio::common::AudioDevice; namespace { // Port handle used when CSD is computed on all devices. Should be a different value than // AUDIO_PORT_HANDLE_NONE which is associated with a sound dose callback failure constexpr audio_port_handle_t CSD_ON_ALL_DEVICES_PORT_HANDLE = -1; int64_t getMonotonicSecond() { struct timespec now_ts; if (clock_gettime(CLOCK_MONOTONIC, &now_ts) != 0) { Loading Loading @@ -175,6 +179,13 @@ void SoundDoseManager::removeStreamProcessor(audio_io_handle_t streamHandle) { } audio_port_handle_t SoundDoseManager::getIdForAudioDevice(const AudioDevice& audioDevice) const { if (isComputeCsdForcedOnAllDevices()) { // If CSD is forced on all devices return random port id. Used only in testing. // This is necessary since the patches that are registered before // setComputeCsdOnAllDevices will not be contributing to mActiveDevices return CSD_ON_ALL_DEVICES_PORT_HANDLE; } const std::lock_guard _l(mLock); audio_devices_t type; Loading Loading @@ -491,7 +502,7 @@ bool SoundDoseManager::shouldComputeCsdForDeviceType(audio_devices_t device) { ALOGV("%s csd is disabled", __func__); return false; } if (forceComputeCsdOnAllDevices()) { if (isComputeCsdForcedOnAllDevices()) { return true; } Loading @@ -515,7 +526,7 @@ bool SoundDoseManager::shouldComputeCsdForDeviceWithAddress(const audio_devices_ ALOGV("%s csd is disabled", __func__); return false; } if (forceComputeCsdOnAllDevices()) { if (isComputeCsdForcedOnAllDevices()) { return true; } Loading @@ -536,7 +547,7 @@ void SoundDoseManager::setUseFrameworkMel(bool useFrameworkMel) { mUseFrameworkMel = useFrameworkMel; } bool SoundDoseManager::forceUseFrameworkMel() const { bool SoundDoseManager::isFrameworkMelForced() const { const std::lock_guard _l(mLock); return mUseFrameworkMel; } Loading @@ -546,7 +557,7 @@ void SoundDoseManager::setComputeCsdOnAllDevices(bool computeCsdOnAllDevices) { mComputeCsdOnAllDevices = computeCsdOnAllDevices; } bool SoundDoseManager::forceComputeCsdOnAllDevices() const { bool SoundDoseManager::isComputeCsdForcedOnAllDevices() const { const std::lock_guard _l(mLock); return mComputeCsdOnAllDevices; } Loading services/audioflinger/sounddose/SoundDoseManager.h +2 −2 Original line number Diff line number Diff line Loading @@ -136,8 +136,8 @@ public: // used for testing only size_t getCachedMelRecordsSize() const; bool forceUseFrameworkMel() const; bool forceComputeCsdOnAllDevices() const; bool isFrameworkMelForced() const; bool isComputeCsdForcedOnAllDevices() const; /** Method for converting from audio_utils::CsdRecord to media::SoundDoseRecord. */ static media::SoundDoseRecord csdRecordToSoundDoseRecord(const audio_utils::CsdRecord& legacy); Loading services/audioflinger/sounddose/tests/sounddosemanager_tests.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -262,11 +262,11 @@ TEST_F(SoundDoseManagerTest, GetUnmappedIdReturnsHandleNone) { } TEST_F(SoundDoseManagerTest, GetDefaultForceComputeCsdOnAllDevices) { EXPECT_FALSE(mSoundDoseManager->forceComputeCsdOnAllDevices()); EXPECT_FALSE(mSoundDoseManager->isComputeCsdForcedOnAllDevices()); } TEST_F(SoundDoseManagerTest, GetDefaultForceUseFrameworkMel) { EXPECT_FALSE(mSoundDoseManager->forceUseFrameworkMel()); EXPECT_FALSE(mSoundDoseManager->isFrameworkMelForced()); } TEST_F(SoundDoseManagerTest, SetAudioDeviceCategoryStopsNonHeadphone) { Loading Loading
services/audioflinger/MelReporter.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ namespace android { bool MelReporter::activateHalSoundDoseComputation(const std::string& module, const sp<DeviceHalInterface>& device) { if (mSoundDoseManager->forceUseFrameworkMel()) { if (mSoundDoseManager->isFrameworkMelForced()) { ALOGD("%s: Forcing use of internal MEL computation.", __func__); activateInternalSoundDoseComputation(); return false; Loading Loading @@ -318,7 +318,7 @@ std::optional<audio_patch_handle_t> MelReporter::activePatchStreamHandle_l( } bool MelReporter::useHalSoundDoseInterface_l() { return !mSoundDoseManager->forceUseFrameworkMel() & mUseHalSoundDoseInterface; return !mSoundDoseManager->isFrameworkMelForced() & mUseHalSoundDoseInterface; } std::string MelReporter::dump() { Loading
services/audioflinger/sounddose/SoundDoseManager.cpp +15 −4 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ using aidl::android::media::audio::common::AudioDevice; namespace { // Port handle used when CSD is computed on all devices. Should be a different value than // AUDIO_PORT_HANDLE_NONE which is associated with a sound dose callback failure constexpr audio_port_handle_t CSD_ON_ALL_DEVICES_PORT_HANDLE = -1; int64_t getMonotonicSecond() { struct timespec now_ts; if (clock_gettime(CLOCK_MONOTONIC, &now_ts) != 0) { Loading Loading @@ -175,6 +179,13 @@ void SoundDoseManager::removeStreamProcessor(audio_io_handle_t streamHandle) { } audio_port_handle_t SoundDoseManager::getIdForAudioDevice(const AudioDevice& audioDevice) const { if (isComputeCsdForcedOnAllDevices()) { // If CSD is forced on all devices return random port id. Used only in testing. // This is necessary since the patches that are registered before // setComputeCsdOnAllDevices will not be contributing to mActiveDevices return CSD_ON_ALL_DEVICES_PORT_HANDLE; } const std::lock_guard _l(mLock); audio_devices_t type; Loading Loading @@ -491,7 +502,7 @@ bool SoundDoseManager::shouldComputeCsdForDeviceType(audio_devices_t device) { ALOGV("%s csd is disabled", __func__); return false; } if (forceComputeCsdOnAllDevices()) { if (isComputeCsdForcedOnAllDevices()) { return true; } Loading @@ -515,7 +526,7 @@ bool SoundDoseManager::shouldComputeCsdForDeviceWithAddress(const audio_devices_ ALOGV("%s csd is disabled", __func__); return false; } if (forceComputeCsdOnAllDevices()) { if (isComputeCsdForcedOnAllDevices()) { return true; } Loading @@ -536,7 +547,7 @@ void SoundDoseManager::setUseFrameworkMel(bool useFrameworkMel) { mUseFrameworkMel = useFrameworkMel; } bool SoundDoseManager::forceUseFrameworkMel() const { bool SoundDoseManager::isFrameworkMelForced() const { const std::lock_guard _l(mLock); return mUseFrameworkMel; } Loading @@ -546,7 +557,7 @@ void SoundDoseManager::setComputeCsdOnAllDevices(bool computeCsdOnAllDevices) { mComputeCsdOnAllDevices = computeCsdOnAllDevices; } bool SoundDoseManager::forceComputeCsdOnAllDevices() const { bool SoundDoseManager::isComputeCsdForcedOnAllDevices() const { const std::lock_guard _l(mLock); return mComputeCsdOnAllDevices; } Loading
services/audioflinger/sounddose/SoundDoseManager.h +2 −2 Original line number Diff line number Diff line Loading @@ -136,8 +136,8 @@ public: // used for testing only size_t getCachedMelRecordsSize() const; bool forceUseFrameworkMel() const; bool forceComputeCsdOnAllDevices() const; bool isFrameworkMelForced() const; bool isComputeCsdForcedOnAllDevices() const; /** Method for converting from audio_utils::CsdRecord to media::SoundDoseRecord. */ static media::SoundDoseRecord csdRecordToSoundDoseRecord(const audio_utils::CsdRecord& legacy); Loading
services/audioflinger/sounddose/tests/sounddosemanager_tests.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -262,11 +262,11 @@ TEST_F(SoundDoseManagerTest, GetUnmappedIdReturnsHandleNone) { } TEST_F(SoundDoseManagerTest, GetDefaultForceComputeCsdOnAllDevices) { EXPECT_FALSE(mSoundDoseManager->forceComputeCsdOnAllDevices()); EXPECT_FALSE(mSoundDoseManager->isComputeCsdForcedOnAllDevices()); } TEST_F(SoundDoseManagerTest, GetDefaultForceUseFrameworkMel) { EXPECT_FALSE(mSoundDoseManager->forceUseFrameworkMel()); EXPECT_FALSE(mSoundDoseManager->isFrameworkMelForced()); } TEST_F(SoundDoseManagerTest, SetAudioDeviceCategoryStopsNonHeadphone) { Loading