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

Commit e3d1f553 authored by jiabin's avatar jiabin
Browse files

Invalidate all other clients when bit-perfect playback becomes active.

When bit-perfect playback becomes active, the framework should
ensure there is only one active stream so that the HAL knows which
configuration to open the sink. In that case, when bit-perfect
playback become active, invalidate all clients that will then be
routed to bit-perfect sink.

Bug: 287088377
Test: atest audiopolicy_tests
Change-Id: Iadf207d273e2301f5976b48dbd2f08f859473226
parent 1579be6d
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -2148,6 +2148,26 @@ status_t AudioPolicyManager::startOutput(audio_port_handle_t portId)
                return DEAD_OBJECT;
            }
            info->increaseActiveClient();
            if (info->getActiveClientCount() == 1 &&
                (info->getFlags() & AUDIO_OUTPUT_FLAG_BIT_PERFECT) != AUDIO_OUTPUT_FLAG_NONE) {
                // 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;
                for (size_t i = 0; i < mOutputs.size(); i++) {
                    if (mOutputs[i] == outputDesc ||
                        !mOutputs[i]->devices().filter(outputDesc->devices()).isEmpty()) {
                        continue;
                    }
                    for (const auto& c : mOutputs[i]->getClientIterable()) {
                        clientsToInvalidate.push_back(c->portId());
                    }
                }
                if (!clientsToInvalidate.empty()) {
                    ALOGD("%s Invalidate clients due to first bit-perfect client started",
                          __func__);
                    mpClientInterface->invalidateTracks(clientsToInvalidate);
                }
            }
        }
    }