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

Commit d332bc8b authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: fix eligibility condition for spatialization

Only tracks with linear PCM audio format can be spatialized with current
architecture.

Bug: 290550088
Test: atest testCreateDirectAudioTracksOnlyForGetDirectProfilesForAttributes
Test: atest SpatializerTest
Change-Id: I5da4265eb6332541da18c0d06145bdde94873ff5
parent ac2d80f9
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -5912,22 +5912,26 @@ bool AudioPolicyManager::canBeSpatializedInt(const audio_attributes_t *attr,
        }
    }

    sp<IOProfile> profile =
            getSpatializerOutputProfile(config, devices);
    if (profile == nullptr) {
        return false;
    }

    // The caller can have the audio config criteria ignored by either passing a null ptr or
    // the AUDIO_CONFIG_INITIALIZER value.
    // If an audio config is specified, current policy is to only allow spatialization for
    // some positional channel masks.
    // some positional channel masks and PCM format

    if (config != nullptr && *config != AUDIO_CONFIG_INITIALIZER) {
        if (!audio_is_channel_mask_spatialized(config->channel_mask)) {
            return false;
        }
        if (!audio_is_linear_pcm(config->format)) {
            return false;
        }
    }

    sp<IOProfile> profile =
            getSpatializerOutputProfile(config, devices);
    if (profile == nullptr) {
        return false;
    }

    return true;
}