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

Commit f4b3951d authored by Sungtak Lee's avatar Sungtak Lee
Browse files

Do not create Codec2Client when IConfigurable is not accessible

Bug: 247689681

Change-Id: Ie3c0130a7682b3b091bdc882324ee93258221228
Merged-In: Ie3c0130a7682b3b091bdc882324ee93258221228
parent 3d1aa862
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -770,16 +770,9 @@ struct Codec2Client::Component::OutputBufferQueue :

// Codec2Client
Codec2Client::Codec2Client(sp<Base> const& base,
                           sp<c2_hidl::IConfigurable> const& configurable,
                           size_t serviceIndex)
      : Configurable{
            [base]() -> sp<c2_hidl::IConfigurable> {
                Return<sp<c2_hidl::IConfigurable>> transResult =
                        base->getConfigurable();
                return transResult.isOk() ?
                        static_cast<sp<c2_hidl::IConfigurable>>(transResult) :
                        nullptr;
            }()
        },
      : Configurable{configurable},
        mBase1_0{base},
        mBase1_1{Base1_1::castFrom(base)},
        mBase1_2{Base1_2::castFrom(base)},
@@ -1163,7 +1156,11 @@ std::shared_ptr<Codec2Client> Codec2Client::_CreateFromIndex(size_t index) {
    CHECK(baseStore) << "Codec2 service \"" << name << "\""
                        " inaccessible for unknown reasons.";
    LOG(VERBOSE) << "Client to Codec2 service \"" << name << "\" created";
    return std::make_shared<Codec2Client>(baseStore, index);
    Return<sp<IConfigurable>> transResult = baseStore->getConfigurable();
    CHECK(transResult.isOk()) << "Codec2 service \"" << name << "\""
                                "does not have IConfigurable.";
    sp<IConfigurable> configurable = static_cast<sp<IConfigurable>>(transResult);
    return std::make_shared<Codec2Client>(baseStore, configurable, index);
}

c2_status_t Codec2Client::ForAllServices(
+7 −2
Original line number Diff line number Diff line
@@ -178,6 +178,8 @@ struct Codec2Client : public Codec2ConfigurableClient {
    typedef ::android::hardware::media::c2::V1_2::IComponentStore Base1_2;
    typedef Base1_0 Base;

    typedef ::android::hardware::media::c2::V1_0::IConfigurable IConfigurable;

    struct Listener;

    typedef Codec2ConfigurableClient Configurable;
@@ -262,8 +264,11 @@ struct Codec2Client : public Codec2ConfigurableClient {
    static std::shared_ptr<InputSurface> CreateInputSurface(
            char const* serviceName = nullptr);

    // base cannot be null.
    Codec2Client(sp<Base> const& base, size_t serviceIndex);
    // base and/or configurable cannot be null.
    Codec2Client(
            sp<Base> const& base,
            sp<IConfigurable> const& configurable,
            size_t serviceIndex);

protected:
    sp<Base1_0> mBase1_0;