Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b648e59 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

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
parent a73556cb
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -8093,6 +8093,9 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves,
                                               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 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves,
    }

    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;
    }