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

Commit 49256858 authored by jiabin's avatar jiabin
Browse files

No need to consider invalid tracks when checking if all active tracks are rerouted.

When a track is invalid, it will be removed later. In that case, there
is no need to consider such tracks when checking if all active tracks
will be rerouted.

Bug: 175343099
Test: connect/disconnect BT when playing music
Change-Id: I074b861af1f59affaf21b4ae5614512265464e1d
parent 3c56c244
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -437,6 +437,8 @@ public:

    uint32_t getRecommendedMuteDurationMs() const override;

    void setTracksInvalidatedStatusByStrategy(product_strategy_t strategy);

    const sp<IOProfile> mProfile;          // I/O profile this output derives from
    audio_io_handle_t mIoHandle;           // output handle
    uint32_t mLatency;                  //
+9 −0
Original line number Diff line number Diff line
@@ -143,6 +143,14 @@ public:
    }
    uint32_t getActivityCount() const { return mActivityCount; }

    bool isInvalid() const {
        return mIsInvalid;
    }

    void setIsInvalid() {
        mIsInvalid = true;
    }

private:
    const audio_stream_type_t mStream;
    const product_strategy_t mStrategy;
@@ -155,6 +163,7 @@ private:
     * involved in a duplication.
     */
    uint32_t mActivityCount = 0;
    bool mIsInvalid = false;
};

class RecordClientDescriptor: public ClientDescriptor
+8 −0
Original line number Diff line number Diff line
@@ -726,6 +726,14 @@ uint32_t SwAudioOutputDescriptor::getRecommendedMuteDurationMs() const
    return mProfile->recommendedMuteDurationMs;
}

void SwAudioOutputDescriptor::setTracksInvalidatedStatusByStrategy(product_strategy_t strategy) {
    for (const auto &client : getClientIterable()) {
        if (strategy == client->strategy()) {
            client->setIsInvalid();
        }
    }
}

// HwAudioOutputDescriptor implementation
HwAudioOutputDescriptor::HwAudioOutputDescriptor(const sp<SourceClientDescriptor>& source,
                                                 AudioPolicyClientInterface *clientInterface)
+10 −1
Original line number Diff line number Diff line
@@ -6188,6 +6188,12 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr
            for (auto stream :  mEngine->getStreamTypesForProductStrategy(psId)) {
                mpClientInterface->invalidateStream(stream);
            }
            for (audio_io_handle_t srcOut : srcOutputs) {
                sp<SwAudioOutputDescriptor> desc = mPreviousOutputs.valueFor(srcOut);
                if (desc == nullptr) continue;

                desc->setTracksInvalidatedStatusByStrategy(psId);
            }
        }
    }
}
@@ -7509,7 +7515,10 @@ bool AudioPolicyManager::areAllActiveTracksRerouted(const sp<SwAudioOutputDescri
        routedDevices.add(device);
    }
    for (const auto& client : activeClients) {
        // TODO: b/175343099 only travel the valid client
        if (client->isInvalid()) {
            // No need to take care about invalidated clients.
            continue;
        }
        sp<DeviceDescriptor> preferredDevice =
                mAvailableOutputDevices.getDeviceFromId(client->preferredDeviceId());
        if (mEngine->getOutputDevicesForAttributes(