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

Commit 2265c1de authored by Shunkai Yao's avatar Shunkai Yao Committed by Automerger Merge Worker
Browse files

Merge "merge hasOrphanEffectsForSessionAndType to hasOrphansForSession" into main am: 09423d0f

parents 75c125c0 09423d0f
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -100,20 +100,19 @@ public:
     */
    audio_io_handle_t getIoForSession(audio_session_t sessionId,
                                      const effect_uuid_t* effectType = nullptr) const;
    bool hasOrphansForSession(audio_session_t sessionId) const;
    EffectDescriptorCollection getOrphanEffectsForSession(audio_session_t sessionId) const;
    void dump(String8 *dst, int spaces = 0, bool verbose = true) const;

    /**
     * @brief Checks if there is at least one orphan effect with given sessionId and effect type
     * uuid.
     * @brief Checks if there is at least one orphan effect with given sessionId and optional effect
     * type uuid.
     * @param sessionId Session ID.
     * @param effectType Effect type UUID, the implementation will be same as hasOrphansForSession
     * if null.
     * @param effectType Optional effect type UUID pointer to effect_uuid_t, nullptr by default.
     * @return True if there is an orphan effect for given sessionId and type UUID, false otherwise.
     */
    bool hasOrphanEffectsForSessionAndType(audio_session_t sessionId,
                                           const effect_uuid_t* effectType) const;
    bool hasOrphansForSession(audio_session_t sessionId,
                              const effect_uuid_t* effectType = nullptr) const;

    EffectDescriptorCollection getOrphanEffectsForSession(audio_session_t sessionId) const;
    void dump(String8 *dst, int spaces = 0, bool verbose = true) const;

private:
    status_t setEffectEnabled(const sp<EffectDescriptor> &effectDesc, bool enabled);
+5 −19
Original line number Diff line number Diff line
@@ -210,27 +210,13 @@ void EffectDescriptorCollection::moveEffects(const std::vector<int>& ids, audio_
    }
}

bool EffectDescriptorCollection::hasOrphansForSession(audio_session_t sessionId) const
{
bool EffectDescriptorCollection::hasOrphansForSession(audio_session_t sessionId,
                                                      const effect_uuid_t* effectType) const {
    for (size_t i = 0; i < size(); ++i) {
        sp<EffectDescriptor> effect = valueAt(i);
        if (effect->mSession == sessionId && effect->mIsOrphan) {
            return true;
        }
    }
    return false;
}

bool EffectDescriptorCollection::hasOrphanEffectsForSessionAndType(
        audio_session_t sessionId, const effect_uuid_t* effectType) const {
    if (effectType == nullptr) {
        return hasOrphansForSession(sessionId);
    }

    for (size_t i = 0; i < size(); ++i) {
        sp<EffectDescriptor> effect = valueAt(i);
        if (effect->mIsOrphan && effect->mSession == sessionId &&
            memcmp(&effect->mDesc.type, effectType, sizeof(effect_uuid_t)) == 0) {
        if (effect->mSession == sessionId && effect->mIsOrphan &&
            (effectType == nullptr ||
             memcmp(&effect->mDesc.type, effectType, sizeof(effect_uuid_t)) == 0)) {
            return true;
        }
    }
+2 −3
Original line number Diff line number Diff line
@@ -2143,8 +2143,7 @@ audio_io_handle_t AudioPolicyManager::selectOutput(const SortedVector<audio_io_h
    // matching criteria values in priority order for best matching output so far
    std::vector<uint32_t> bestMatchCriteria(8, 0);

    const bool hasOrphanHaptic =
            mEffects.hasOrphanEffectsForSessionAndType(sessionId, FX_IID_HAPTICGENERATOR);
    const bool hasOrphanHaptic = mEffects.hasOrphansForSession(sessionId, FX_IID_HAPTICGENERATOR);
    const uint32_t channelCount = audio_channel_count_from_out_mask(channelMask);
    const uint32_t hapticChannelCount = audio_channel_count_from_out_mask(
        channelMask & AUDIO_CHANNEL_HAPTIC_ALL);
@@ -6284,7 +6283,7 @@ bool AudioPolicyManager::checkHapticCompatibilityOnSpatializerOutput(
        // means haptic use cases (either the client channelmask includes haptic bits, or created a
        // HapticGenerator effect for this session) are not supported.
        return clientHapticChannel == 0 &&
               !mEffects.hasOrphanEffectsForSessionAndType(sessionId, FX_IID_HAPTICGENERATOR);
               !mEffects.hasOrphansForSession(sessionId, FX_IID_HAPTICGENERATOR);
    }
}