CSD: fix logic for new patches with CSD HAL path
The mActiveDevices is configured with every new patch and is used to
make the connection between the received csd callbacks and the
registered devices. The logic for new patches in onCreatePatch needs to
be retained even when the HAL path is enabled for CSD.
Test: manual test
Bug: 272260521
Change-Id: Ia27c4ffe6113ea2a56bd412a14cbf6dfc20a622c
diff --git a/services/audioflinger/MelReporter.cpp b/services/audioflinger/MelReporter.cpp
index 496aedc..5a3bcdc 100644
--- a/services/audioflinger/MelReporter.cpp
+++ b/services/audioflinger/MelReporter.cpp
@@ -147,10 +147,6 @@
ALOGV("%s csd is disabled", __func__);
return;
}
- if (useHalSoundDoseInterface()) {
- ALOGV("%s using HAL sound dose, ignore new patch", __func__);
- return;
- }
ALOGV("%s: handle %d mHalHandle %d device sink %08x",
__func__, handle, patch.mHalHandle,
@@ -199,7 +195,7 @@
ALOGI("%s add stream %d that uses device %d for CSD, nr of streams: %d", __func__,
patch.streamHandle, deviceHandle, mActiveDevices[deviceHandle]);
- if (outputThread != nullptr) {
+ if (outputThread != nullptr && !useHalSoundDoseInterface_l()) {
outputThread->startMelComputation_l(mSoundDoseManager->getOrCreateProcessorForDevice(
deviceHandle,
patch.streamHandle,
@@ -271,7 +267,7 @@
}
}
- if (outputThread != nullptr) {
+ if (outputThread != nullptr && !useHalSoundDoseInterface_l()) {
outputThread->stopMelComputation_l();
}
}
@@ -287,13 +283,8 @@
return std::nullopt;
}
-bool AudioFlinger::MelReporter::useHalSoundDoseInterface() {
- bool useHalSoundDoseInterface = !mSoundDoseManager->forceUseFrameworkMel();
- {
- std::lock_guard _l(mLock);
- useHalSoundDoseInterface &= mUseHalSoundDoseInterface;
- }
- return useHalSoundDoseInterface;
+bool AudioFlinger::MelReporter::useHalSoundDoseInterface_l() {
+ return !mSoundDoseManager->forceUseFrameworkMel() & mUseHalSoundDoseInterface;
}
std::string AudioFlinger::MelReporter::dump() {