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

Commit 0ebd2ed4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "C2ComponentStore::createComponent"

* changes:
  Fix build breakage in C2Decoder and C2Encoder
  Fix build breakage in VtsHalMediaC2V1_0TargetMasterTest.
  codec2: propagate C2_NO_MEMORY from C2ComponentStore::createComponent()
parents 977a79de f23f9e5c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -73,9 +73,10 @@ TEST_P(Codec2MasterHalTest, ListComponents) {
            ASSERT_NE(listener, nullptr);

            // Create component from all known services
            component =
                    mClient->CreateComponentByName(listTraits[i].name.c_str(), listener, &mClient);
            ASSERT_NE(component, nullptr)
            const c2_status_t status =
                    android::Codec2Client::CreateComponentByName(
                            listTraits[i].name.c_str(), listener, &component, &mClient);
            ASSERT_EQ(status, C2_OK)
                    << "Create component failed for " << listTraits[i].name.c_str();
        }
    }
+7 −6
Original line number Diff line number Diff line
@@ -1008,6 +1008,8 @@ c2_status_t Codec2Client::ForAllServices(
                std::scoped_lock lock{key2IndexMutex};
                key2Index[key] = index; // update last known client index
                return C2_OK;
            } else if (status == C2_NO_MEMORY) {
                return C2_NO_MEMORY;
            } else if (status == C2_TRANSACTION_FAILED) {
                LOG(WARNING) << "\"" << key << "\" failed for service \""
                             << client->getName()
@@ -1028,24 +1030,23 @@ c2_status_t Codec2Client::ForAllServices(
    return status; // return the last status from a valid client
}

std::shared_ptr<Codec2Client::Component>
        Codec2Client::CreateComponentByName(
c2_status_t Codec2Client::CreateComponentByName(
        const char* componentName,
        const std::shared_ptr<Listener>& listener,
        std::shared_ptr<Component>* component,
        std::shared_ptr<Codec2Client>* owner,
        size_t numberOfAttempts) {
    std::string key{"create:"};
    key.append(componentName);
    std::shared_ptr<Component> component;
    c2_status_t status = ForAllServices(
            key,
            numberOfAttempts,
            [owner, &component, componentName, &listener](
            [owner, component, componentName, &listener](
                    const std::shared_ptr<Codec2Client> &client)
                        -> c2_status_t {
                c2_status_t status = client->createComponent(componentName,
                                                             listener,
                                                             &component);
                                                             component);
                if (status == C2_OK) {
                    if (owner) {
                        *owner = client;
@@ -1064,7 +1065,7 @@ std::shared_ptr<Codec2Client::Component>
                   << "\" from all known services. "
                      "Last returned status = " << status << ".";
    }
    return component;
    return status;
}

std::shared_ptr<Codec2Client::Interface>
+2 −1
Original line number Diff line number Diff line
@@ -200,9 +200,10 @@ struct Codec2Client : public Codec2ConfigurableClient {
    // Try to create a component with a given name from all known
    // IComponentStore services. numberOfAttempts determines the number of times
    // to retry the HIDL call if the transaction fails.
    static std::shared_ptr<Component> CreateComponentByName(
    static c2_status_t CreateComponentByName(
            char const* componentName,
            std::shared_ptr<Listener> const& listener,
            std::shared_ptr<Component>* component,
            std::shared_ptr<Codec2Client>* owner = nullptr,
            size_t numberOfAttempts = 10);

+6 −5
Original line number Diff line number Diff line
@@ -645,17 +645,18 @@ void CCodec::allocate(const sp<MediaCodecInfo> &codecInfo) {
                std::make_shared<Codec2ClientInterfaceWrapper>(client));
    }

    std::shared_ptr<Codec2Client::Component> comp =
            Codec2Client::CreateComponentByName(
    std::shared_ptr<Codec2Client::Component> comp;
    c2_status_t status = Codec2Client::CreateComponentByName(
            componentName.c_str(),
            mClientListener,
            &comp,
            &client);
    if (!comp) {
        ALOGE("Failed Create component: %s", componentName.c_str());
    if (status != C2_OK) {
        ALOGE("Failed Create component: %s, error=%d", componentName.c_str(), status);
        Mutexed<State>::Locked state(mState);
        state->set(RELEASED);
        state.unlock();
        mCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
        mCallback->onError((status == C2_NO_MEMORY ? NO_MEMORY : UNKNOWN_ERROR), ACTION_CODE_FATAL);
        state.lock();
        return;
    }
+2 −2
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ int32_t C2Decoder::createCodec2Component(string compName, AMediaFormat *format)
    }

    int64_t sTime = mStats->getCurTime();
    mComponent = mClient->CreateComponentByName(compName.c_str(), mListener, &mClient);
    if (mComponent == nullptr) {
    if (mClient->CreateComponentByName(compName.c_str(), mListener, &mComponent, &mClient) !=
        C2_OK) {
        ALOGE("Create component failed for %s", compName.c_str());
        return -1;
    }
Loading