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

Commit 514297fc authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Reset output device when a bit-perfect client becomes active." into main

parents 0cb96ed3 e6b87495
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2378,11 +2378,15 @@ status_t AudioPolicyManager::startOutput(audio_port_handle_t portId)
                // If it is first bit-perfect client, reroute all clients that will be routed to
                // the bit-perfect sink so that it is guaranteed only bit-perfect stream is active.
                PortHandleVector clientsToInvalidate;
                std::vector<sp<SwAudioOutputDescriptor>> outputsToResetDevice;
                for (size_t i = 0; i < mOutputs.size(); i++) {
                    if (mOutputs[i] == outputDesc || (!mOutputs[i]->devices().isEmpty() &&
                        mOutputs[i]->devices().filter(outputDesc->devices()).isEmpty())) {
                        continue;
                    }
                    if (mOutputs[i]->getPatchHandle() != AUDIO_PATCH_HANDLE_NONE) {
                        outputsToResetDevice.push_back(mOutputs[i]);
                    }
                    for (const auto& c : mOutputs[i]->getClientIterable()) {
                        clientsToInvalidate.push_back(c->portId());
                    }
@@ -2392,6 +2396,9 @@ status_t AudioPolicyManager::startOutput(audio_port_handle_t portId)
                          __func__);
                    mpClientInterface->invalidateTracks(clientsToInvalidate);
                }
                for (const auto& output : outputsToResetDevice) {
                    resetOutputDevice(output, 0 /*delayMs*/, nullptr /*patchHandle*/);
                }
            }
        }
    }