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

Commit 68179457 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "audio policy: invalidate tracks when selected devices become...

Merge "audio policy: invalidate tracks when selected devices become unreachable" into main am: 09de3463

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3242365



Change-Id: I4b4f2b628b1c7a3b98003c3462f9f48d0764ba3d
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dc30635f 09de3463
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -7269,28 +7269,35 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr
    std::vector<sp<SwAudioOutputDescriptor>> invalidatedOutputs;
    // take into account dynamic audio policies related changes: if a client is now associated
    // to a different policy mix than at creation time, invalidate corresponding stream
    // invalidate clients on outputs that do not support all the newly selected devices for the
    // strategy
    for (size_t i = 0; i < mPreviousOutputs.size(); i++) {
        const sp<SwAudioOutputDescriptor>& desc = mPreviousOutputs.valueAt(i);
        if (desc->isDuplicated()) {
        if (desc->isDuplicated() || desc->getClientCount() == 0) {
            continue;
        }

        for (const sp<TrackClientDescriptor>& client : desc->getClientIterable()) {
            if (mEngine->getProductStrategyForAttributes(client->attributes()) != psId) {
                continue;
            }
            if (!desc->supportsAllDevices(newDevices)) {
                invalidatedOutputs.push_back(desc);
                break;
            }
            sp<AudioPolicyMix> primaryMix;
            status_t status = mPolicyMixes.getOutputForAttr(client->attributes(), client->config(),
                    client->uid(), client->session(), client->flags(), mAvailableOutputDevices,
                    nullptr /* requestedDevice */, primaryMix, nullptr /* secondaryMixes */,
                    unneededUsePrimaryOutputFromPolicyMixes);
            if (status != OK) {
                continue;
            }
            if (status == OK) {
                if (client->getPrimaryMix() != primaryMix || client->hasLostPrimaryMix()) {
                    if (desc->isStrategyActive(psId) && maxLatency < desc->latency()) {
                        maxLatency = desc->latency();
                    }
                    invalidatedOutputs.push_back(desc);
                    break;
                }
            }
        }
    }