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

Commit dfc5c98a authored by Arun Johnson's avatar Arun Johnson Committed by Automerger Merge Worker
Browse files

Merge "Moving MultiAccessunitInterface to ComponentStore" into main am: 586f6cb9 am: bddb0c8a

parents 8becaab2 bddb0c8a
Loading
Loading
Loading
Loading
+1 −24
Original line number Diff line number Diff line
@@ -205,30 +205,7 @@ Component::Component(
        mDeathContext(nullptr) {
    // Retrieve supported parameters from store
    // TODO: We could cache this per component/interface type
    if (MultiAccessUnitHelper::isEnabledOnPlatform()) {
        c2_status_t err = C2_OK;
        C2ComponentDomainSetting domain;
        std::vector<std::unique_ptr<C2Param>> heapParams;
        err = component->intf()->query_vb({&domain}, {}, C2_MAY_BLOCK, &heapParams);
        if (err == C2_OK && (domain.value == C2Component::DOMAIN_AUDIO)) {
            std::vector<std::shared_ptr<C2ParamDescriptor>> params;
            bool isComponentSupportsLargeAudioFrame = false;
            component->intf()->querySupportedParams_nb(&params);
            for (const auto &paramDesc : params) {
                if (paramDesc->name().compare(C2_PARAMKEY_OUTPUT_LARGE_FRAME) == 0) {
                    isComponentSupportsLargeAudioFrame = true;
                    LOG(VERBOSE) << "Underlying component supports large frame audio";
                    break;
                }
            }
            if (!isComponentSupportsLargeAudioFrame) {
                mMultiAccessUnitIntf = std::make_shared<MultiAccessUnitInterface>(
                        component->intf(),
                        std::static_pointer_cast<C2ReflectorHelper>(
                                ::android::GetCodec2PlatformComponentStore()->getParamReflector()));
            }
        }
    }
    mMultiAccessUnitIntf = store->tryCreateMultiAccessUnitInterface(component->intf());
    mInterface = SharedRefBase::make<ComponentInterface>(
            component->intf(), mMultiAccessUnitIntf, store->getParameterCache());
    mInit = mInterface->status();
+29 −3
Original line number Diff line number Diff line
@@ -131,9 +131,35 @@ struct CompIntf : public ConfigurableC2Intf {
    virtual c2_status_t querySupportedValues(
            std::vector<C2FieldSupportedValuesQuery>& fields,
            c2_blocking_t mayBlock) const override {
        c2_status_t err = mIntf->querySupportedValues_vb(fields, mayBlock);
        if (mMultiAccessUnitIntf != nullptr) {
            err = mMultiAccessUnitIntf->querySupportedValues(fields, mayBlock);
        if (mMultiAccessUnitIntf == nullptr) {
           return  mIntf->querySupportedValues_vb(fields, mayBlock);
        }
        std::vector<C2FieldSupportedValuesQuery> dup = fields;
        std::vector<C2FieldSupportedValuesQuery> queryArray[2];
        std::map<C2ParamField, std::pair<uint32_t, size_t>> queryMap;
        c2_status_t err = C2_OK;
        for (int i = 0 ; i < fields.size(); i++) {
            const C2ParamField &field = fields[i].field();
            uint32_t queryArrayIdx = 1;
            if (mMultiAccessUnitIntf->isValidField(fields[i].field())) {
                queryArrayIdx = 0;
            }
            queryMap[field] = std::make_pair(
                    queryArrayIdx, queryArray[queryArrayIdx].size());
            queryArray[queryArrayIdx].push_back(fields[i]);
        }
        if (queryArray[0].size() > 0) {
            err = mMultiAccessUnitIntf->querySupportedValues(queryArray[0], mayBlock);
        }
        if (queryArray[1].size() > 0) {
             err = mIntf->querySupportedValues_vb(queryArray[1], mayBlock);
        }
        for (int i = 0 ; i < dup.size(); i++) {
            auto it = queryMap.find(dup[i].field());
            if (it != queryMap.end()) {
                std::pair<uint32_t, size_t> queryid = it->second;
                fields[i] = queryArray[queryid.first][queryid.second];
            }
        }
        return err;
    }
+34 −1
Original line number Diff line number Diff line
@@ -199,6 +199,36 @@ std::shared_ptr<FilterWrapper> ComponentStore::GetFilterWrapper() {
}
#endif

std::shared_ptr<MultiAccessUnitInterface> ComponentStore::tryCreateMultiAccessUnitInterface(
        const std::shared_ptr<C2ComponentInterface> &c2interface) {
    std::shared_ptr<MultiAccessUnitInterface> multiAccessUnitIntf = nullptr;
    if (c2interface == nullptr) {
        return nullptr;
    }
    if (MultiAccessUnitHelper::isEnabledOnPlatform()) {
        c2_status_t err = C2_OK;
        C2ComponentDomainSetting domain;
        std::vector<std::unique_ptr<C2Param>> heapParams;
        err = c2interface->query_vb({&domain}, {}, C2_MAY_BLOCK, &heapParams);
        if (err == C2_OK && (domain.value == C2Component::DOMAIN_AUDIO)) {
            std::vector<std::shared_ptr<C2ParamDescriptor>> params;
            bool isComponentSupportsLargeAudioFrame = false;
            c2interface->querySupportedParams_nb(&params);
            for (const auto &paramDesc : params) {
                if (paramDesc->name().compare(C2_PARAMKEY_OUTPUT_LARGE_FRAME) == 0) {
                    isComponentSupportsLargeAudioFrame = true;
                    break;
                }
            }
            if (!isComponentSupportsLargeAudioFrame) {
                multiAccessUnitIntf = std::make_shared<MultiAccessUnitInterface>(
                        c2interface, std::static_pointer_cast<C2ReflectorHelper>(mParamReflector));
            }
        }
    }
    return multiAccessUnitIntf;
}

// Methods from ::aidl::android::hardware::media::c2::IComponentStore
ScopedAStatus ComponentStore::createComponent(
        const std::string& name,
@@ -258,7 +288,10 @@ ScopedAStatus ComponentStore::createInterface(
        c2interface = GetFilterWrapper()->maybeWrapInterface(c2interface);
#endif
        onInterfaceLoaded(c2interface);
        *intf = SharedRefBase::make<ComponentInterface>(c2interface, mParameterCache);
        std::shared_ptr<MultiAccessUnitInterface> multiAccessUnitIntf =
                tryCreateMultiAccessUnitInterface(c2interface);
        *intf = SharedRefBase::make<ComponentInterface>(
                c2interface, multiAccessUnitIntf, mParameterCache);
        return ScopedAStatus::ok();
    }
    return ScopedAStatus::fromServiceSpecificError(res);
+3 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ struct ComponentStore : public BnComponentStore {

    static std::shared_ptr<::android::FilterWrapper> GetFilterWrapper();

    std::shared_ptr<MultiAccessUnitInterface> tryCreateMultiAccessUnitInterface(
            const std::shared_ptr<C2ComponentInterface> &c2interface);

    // Methods from ::aidl::android::hardware::media::c2::IComponentStore.
    virtual ::ndk::ScopedAStatus createComponent(
            const std::string& name,
+5 −0
Original line number Diff line number Diff line
@@ -73,12 +73,17 @@ MultiAccessUnitInterface::MultiAccessUnitInterface(
    for (std::shared_ptr<C2ParamDescriptor> &desc : supportedParams) {
        mSupportedParamIndexSet.insert(desc->index());
    }
    mParamFields.emplace_back(mLargeFrameParams.get(), &(mLargeFrameParams.get()->maxSize));
    mParamFields.emplace_back(mLargeFrameParams.get(), &(mLargeFrameParams.get()->thresholdSize));

    if (mC2ComponentIntf) {
        c2_status_t err = mC2ComponentIntf->query_vb({&mKind}, {}, C2_MAY_BLOCK, nullptr);
    }
}

bool MultiAccessUnitInterface::isValidField(const C2ParamField &field) const {
    return (std::find(mParamFields.begin(), mParamFields.end(), field) != mParamFields.end());
}
bool MultiAccessUnitInterface::isParamSupported(C2Param::Index index) {
    return (mSupportedParamIndexSet.count(index) != 0);
}
Loading