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

Commit 11c14835 authored by Jaideep Sharma's avatar Jaideep Sharma
Browse files

audiopolicy: return appropriate profile from searchCompatibleProfileHwModules

The current logic for getting IoProfile prefers to select a profile with
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD when "directOnly" profiles are
fetched.

However, if configurations support a mixport with exactly
"AUDIO_OUTPUT_FLAG_DIRECT", and a "directOnly" profile is fetched with
"AUDIO_OUTPUT_FLAG_DIRECT", the current logic still ends up providing a
AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD profile. This is because the
compress_offload profile is defined as
(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD | AUDIO_OUTPUT_FLAG_DIRECT).

Modify the logic to check the requested flags. If a profile with
AUDIO_OUTPUT_FLAG_DIRECT is requested and APM has a
AUDIO_OUTPUT_FLAG_DIRECT profile, return the appropriate profile.

Bug: 393531112

Test: run audiopolicy_tests, audiorouting_tests, trackplayerbase_tests ,
audiosystem_tests

Test: CtsMediaAudioTestCases, CtsNativeMediaAAudioTestCases

Change-Id: Ieabe99c5b0fba329195a072583115f6ce5f9c41f
parent 2f5eb682
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -1132,7 +1132,9 @@ sp<IOProfile> AudioPolicyManager::searchCompatibleProfileHwModules (
                                        audio_channel_mask_t channelMask,
                                        audio_output_flags_t flags,
                                        bool directOnly) {
    sp<IOProfile> profile;
    sp<IOProfile> directOnlyProfile = nullptr;
    sp<IOProfile> compressOffloadProfile = nullptr;
    sp<IOProfile> profile = nullptr;
    for (const auto& hwModule : hwModules) {
        for (const auto& curProfile : hwModule->getOutputProfiles()) {
             if (curProfile->getCompatibilityScore(devices,
@@ -1154,19 +1156,21 @@ sp<IOProfile> AudioPolicyManager::searchCompatibleProfileHwModules (
                return curProfile;
             }

             // when searching for direct outputs, if several profiles are compatible, give priority
             // to one with offload capability
             if (profile != 0 &&
                 ((curProfile->getFlags() & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0)) {
                continue;
             }
             profile = curProfile;
             if ((profile->getFlags() & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0) {
                 break;
             if ((flags == AUDIO_OUTPUT_FLAG_DIRECT) &&
                 curProfile->getFlags() == AUDIO_OUTPUT_FLAG_DIRECT) {
                 directOnlyProfile = curProfile;
             }

             if ((curProfile->getFlags() & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0) {
                 compressOffloadProfile = curProfile;
             }
        }
    return profile;
    }

    return directOnlyProfile ? directOnlyProfile
                            : (compressOffloadProfile ? compressOffloadProfile : profile);

}

sp<IOProfile> AudioPolicyManager::getSpatializerOutputProfile(
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@
                </mixPort>
                <mixPort name="compressed_offload" role="source"
                         flags="AUDIO_OUTPUT_FLAG_DIRECT AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD AUDIO_OUTPUT_FLAG_NON_BLOCKING AUDIO_OUTPUT_FLAG_GAPLESS_OFFLOAD">
                    <profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
                             samplingRates="48000 96000 384000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                    <profile name="" format="AUDIO_FORMAT_MP3"
                             samplingRates="8000 16000 24000 32000 44100 48000 96000"
                             channelMasks="AUDIO_CHANNEL_OUT_STEREO AUDIO_CHANNEL_OUT_MONO"/>