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

Commit c42a2025 authored by Ping Tsai's avatar Ping Tsai Committed by Eric Laurent
Browse files

AudioPolicy: Fix music stutter when device connect

Added a check for invalid client descriptors to prevent setting invalidate repeatedly on an invalid track

BUG: 381009246
Test:Manual
1. a2dp non-offload playback music
2. insert 3.5 mm headset
(cherry picked from https://partner-android-review.googlesource.com/q/commit:2f183214ffffa727f9ceef1bbf65e92e1b7b2bfc)
Flag: EXEMPT bug fix
Merged-In: I16ebf953fc9f65d13f680205173c3365c7e01875
Change-Id: I16ebf953fc9f65d13f680205173c3365c7e01875
parent be780057
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -7545,7 +7545,8 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr
        }

        for (const sp<TrackClientDescriptor>& client : desc->getClientIterable()) {
            if (mEngine->getProductStrategyForAttributes(client->attributes()) != psId) {
            if (mEngine->getProductStrategyForAttributes(client->attributes()) != psId
                    || client->isInvalid()) {
                continue;
            }
            if (!desc->supportsAllDevices(newDevices)) {
@@ -7582,6 +7583,9 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr

            bool invalidate = false;
            for (auto client : desc->clientsList(false /*activeOnly*/)) {
                if (client->isInvalid()) {
                    continue;
                }
                if (desc->isDuplicated() || !desc->mProfile->isDirectOutput()) {
                    // a client on a non direct outputs has necessarily a linear PCM format
                    // so we can call selectOutput() safely