Make error log in APM::checkAndSetVolume more useful
Log the contents of the curve which has an invalid index.
Since curves do not change over time, limit logging to one
log message per curve to avoid spamming the log.
Flag: EXEMPT bugfix
Bug: 360937480
Test: atest audiopolicy_tests
Change-Id: Iec9c03e3818bb3a2f92bbce13a42d231964cc438
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 5a51a91..cb12cd6 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -8093,6 +8093,9 @@
int delayMs,
bool force)
{
+ // APM is single threaded, and single instance.
+ static std::set<IVolumeCurves*> invalidCurvesReported;
+
// do not change actual attributes volume if the attributes is muted
if (outputDesc->isMuted(volumeSource)) {
ALOGVV("%s: volume source %d muted count %d active=%d", __func__, volumeSource,
@@ -8117,7 +8120,12 @@
}
if (curves.getVolumeIndexMin() < 0 || curves.getVolumeIndexMax() < 0) {
- ALOGE("invalid volume index range");
+ if (!invalidCurvesReported.count(&curves)) {
+ invalidCurvesReported.insert(&curves);
+ String8 dump;
+ curves.dump(&dump);
+ ALOGE("invalid volume index range in the curve:\n%s", dump.c_str());
+ }
return BAD_VALUE;
}