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

Commit 1f8cf3d2 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

Align AIDL HAL config reporting with legacy

1. In libaudiohal, sort the modules in the "canonical" order,
   as in the reference audio_policy_configuration_7_0.xml file.
   This simplifies A/B comparisons.

2. When building the APM configuration from the one provided
   by the AIDL HAL, insert "dynamic profiles" into the mix port
   if it has an empty set of profiles (same as for device ports).

Bug: 286914845
Bug: 290273817
Test: run CF with AIDL HAL, A/B compare APM dumps with HIDL
Change-Id: Ifc645d0b1318ceaa6a3935bf470f2d045d518800
parent aaec7976
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -14,7 +14,10 @@
 * limitations under the License.
 */

#include <algorithm>
#include <map>
#include <memory>
#include <string>

#define LOG_TAG "DevicesFactoryHalAidl"
//#define LOG_NDEBUG 0
@@ -75,6 +78,21 @@ status_t DevicesFactoryHalAidl::getDeviceNames(std::vector<std::string> *names)
                if (strcmp(instance, "default") == 0) instance = "primary";
                static_cast<decltype(names)>(context)->push_back(instance);
            });
    std::sort(names->begin(), names->end(), [](const std::string& lhs,
                    const std::string& rhs) {
        // This order corresponds to the canonical order of modules as specified in
        // the reference 'audio_policy_configuration_7_0.xml' file.
        static const std::map<std::string, int> kPriorities{
            { "primary", 0 }, { "a2dp", 1 }, { "usb", 2 }, { "r_submix", 3 },
            { "bluetooth", 4 }, { "hearing_aid", 5 }, { "msd", 6 }, { "stub", 7 }
        };
        auto lhsIt = kPriorities.find(lhs);
        auto rhsIt = kPriorities.find(rhs);
        if (lhsIt != kPriorities.end() && rhsIt != kPriorities.end()) {
            return lhsIt->second < rhsIt->second;
        }
        return lhsIt != kPriorities.end();
    });
    return OK;
}

+6 −1
Original line number Diff line number Diff line
@@ -89,7 +89,12 @@ status_t aidl2legacy_AudioHwModule_HwModule(const media::AudioHwModule& aidl,
        if (aidlPort.ext.getTag() == AudioPortExt::mix) {
            auto mixPort = sp<IOProfile>::make("", AUDIO_PORT_ROLE_NONE);
            RETURN_STATUS_IF_ERROR(mixPort->readFromParcelable(fwPort));
            auto& profiles = mixPort->getAudioProfiles();
            if (profiles.empty()) {
                profiles.add(AudioProfile::createFullDynamic(gDynamicFormat));
            } else {
                sortAudioProfiles(mixPort->getAudioProfiles());
            }
            mixPorts.add(mixPort);
            ports.emplace(aidlPort.id, mixPort);
        } else if (aidlPort.ext.getTag() == AudioPortExt::device) {