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

Commit e6b87495 authored by jiabin's avatar jiabin
Browse files

Reset output device when a bit-perfect client becomes active.

When a bit-perfect becomes active, there must only be one mix port
connected to the selected device port. In that case, reset output device
for all outputs that are currently connected to the selected device
port.

Bug: 357786293
Test: switch playback between YTM and DSD file player
Flag: EXEMPT bugfix
Change-Id: I4c59ea1771fb6c1f130d8dce9076b324b1acea5b
parent 865775da
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*/);
                }
            }
        }
    }