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

Commit 3df8a787 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

audio policy: reduce audio routing commands trafic.

am: 77305a67

Change-Id: I1eba9b064de17a0d8d66a38ba1fc6da241c28b58
parents 35b3e0ca 77305a67
Loading
Loading
Loading
Loading
+11 −4
Original line number Original line Diff line number Diff line
@@ -1167,8 +1167,10 @@ status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc,
        beaconMuteLatency = handleEventForBeacon(STARTING_OUTPUT);
        beaconMuteLatency = handleEventForBeacon(STARTING_OUTPUT);
    }
    }


    // force device change if the output is inactive and no audio patch is already present.
    // check active before incrementing usage count
    // check active before incrementing usage count
    bool force = !outputDesc->isActive();
    bool force = !outputDesc->isActive() &&
            (outputDesc->getPatchHandle() == AUDIO_PATCH_HANDLE_NONE);


    // increment usage count for this stream on the requested output:
    // increment usage count for this stream on the requested output:
    // NOTE that the usage count is the same for duplicated output and hardware output which is
    // NOTE that the usage count is the same for duplicated output and hardware output which is
@@ -1188,12 +1190,17 @@ status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc,
        for (size_t i = 0; i < mOutputs.size(); i++) {
        for (size_t i = 0; i < mOutputs.size(); i++) {
            sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i);
            sp<AudioOutputDescriptor> desc = mOutputs.valueAt(i);
            if (desc != outputDesc) {
            if (desc != outputDesc) {
                // force a device change if any other output is managed by the same hw
                // force a device change if any other output is:
                // module and has a current device selection that differs from selected device.
                // - managed by the same hw module
                // - has a current device selection that differs from selected device.
                // - supports currently selected device
                // - has an active audio patch
                // In this case, the audio HAL must receive the new device selection so that it can
                // In this case, the audio HAL must receive the new device selection so that it can
                // change the device currently selected by the other active output.
                // change the device currently selected by the other active output.
                if (outputDesc->sharesHwModuleWith(desc) &&
                if (outputDesc->sharesHwModuleWith(desc) &&
                    desc->device() != device) {
                        desc->device() != device &&
                        desc->supportedDevices() & device &&
                        desc->getPatchHandle() != AUDIO_PATCH_HANDLE_NONE) {
                    force = true;
                    force = true;
                }
                }
                // wait for audio on other active outputs to be presented when starting
                // wait for audio on other active outputs to be presented when starting