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

Commit 0b31cbcc authored by jiabin's avatar jiabin
Browse files

Only consider flags that affect strategy when matching attributes.

When matching attributes to strategy, only some of the audio flags that
will affect the strategy matching. In that case, it is no need to
compare all flags.

Bug: 322810769
Test: atest AudioTrackTest
Change-Id: I000871b6f5278449f8d267cbc37bba8029d56873
parent 618e9492
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -60,9 +60,13 @@ aidl2legacy_AudioProductStrategy(const media::AudioProductStrategy& aidl) {
}
}


// Keep in sync with android/media/audiopolicy/AudioProductStrategy#attributeMatches
// Keep in sync with android/media/audiopolicy/AudioProductStrategy#attributeMatches
int AudioProductStrategy::attributesMatchesScore(const audio_attributes_t refAttributes,
int AudioProductStrategy::attributesMatchesScore(audio_attributes_t refAttributes,
                                                 const audio_attributes_t clientAttritubes)
                                                 audio_attributes_t clientAttritubes)
{
{
    refAttributes.flags = static_cast<audio_flags_mask_t>(
            refAttributes.flags & AUDIO_FLAGS_AFFECT_STRATEGY_SELECTION);
    clientAttritubes.flags = static_cast<audio_flags_mask_t>(
            clientAttritubes.flags & AUDIO_FLAGS_AFFECT_STRATEGY_SELECTION);
    if (refAttributes == clientAttritubes) {
    if (refAttributes == clientAttritubes) {
        return MATCH_EQUALS;
        return MATCH_EQUALS;
    }
    }
+4 −4
Original line number Original line Diff line number Diff line
@@ -58,11 +58,11 @@ public:
     * @return {@code INVALID_SCORE} if not matching, {@code MATCH_ON_DEFAULT_SCORE} if matching
     * @return {@code INVALID_SCORE} if not matching, {@code MATCH_ON_DEFAULT_SCORE} if matching
     * to default strategy, non zero positive score if matching a strategy.
     * to default strategy, non zero positive score if matching a strategy.
     */
     */
    static int attributesMatchesScore(const audio_attributes_t refAttributes,
    static int attributesMatchesScore(audio_attributes_t refAttributes,
                                      const audio_attributes_t clientAttritubes);
                                      audio_attributes_t clientAttritubes);


    static bool attributesMatches(const audio_attributes_t refAttributes,
    static bool attributesMatches(audio_attributes_t refAttributes,
                                      const audio_attributes_t clientAttritubes) {
                                  audio_attributes_t clientAttritubes) {
        return attributesMatchesScore(refAttributes, clientAttritubes) > 0;
        return attributesMatchesScore(refAttributes, clientAttritubes) > 0;
    }
    }