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

Commit 7f82d1a7 authored by Jasmine Cha's avatar Jasmine Cha Committed by Bubble Fang
Browse files

audio policy: fix disordered sequence while changing device



  Disordered sequence will occur when delayMs of muting volume
  and changing path are the same and no additional delay between
  both commands (muteWaitMs == 0).
  Add half reported latency to delayMs for routing could avoid
  processing muting stream volume and switching path concurrently.

Bug: 149798335
Test: Make VoIP/voice call and switch device between handset/handsfree.
      Check if touch tone is truncated in QXDM.

Signed-off-by: default avatarJasmine Cha <chajasmine@google.com>
Change-Id: Ifa15ba9de330805637cfb20ee96c4293c1c1bd31
parent a5d212cf
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -5535,7 +5535,10 @@ uint32_t AudioPolicyManager::setOutputDevices(const sp<SwAudioOutputDescriptor>&
            patchBuilder.addSink(filteredDevice);
        }

        installPatch(__func__, patchHandle, outputDesc.get(), patchBuilder.patch(), delayMs);
        // Add half reported latency to delayMs when muteWaitMs is null in order
        // to avoid disordered sequence of muting volume and changing devices.
        installPatch(__func__, patchHandle, outputDesc.get(), patchBuilder.patch(),
                muteWaitMs == 0 ? (delayMs + (outputDesc->latency() / 2)) : delayMs);
    }

    // update stream volumes according to new device