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

Commit 49240608 authored by Shunkai Yao's avatar Shunkai Yao Committed by Automerger Merge Worker
Browse files

Merge "AIDL effect: add dynamic libraries open check" am: b490783a

parents 394cdfbb b490783a
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -165,7 +165,7 @@ ndk::ScopedAStatus Factory::destroyEffect(const std::shared_ptr<IEffect>& in_han
    return status;
    return status;
}
}


void Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libName) {
bool Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libName) {
    std::function<void(void*)> dlClose = [](void* handle) -> void {
    std::function<void(void*)> dlClose = [](void* handle) -> void {
        if (handle && dlclose(handle)) {
        if (handle && dlclose(handle)) {
            LOG(ERROR) << "dlclose failed " << dlerror();
            LOG(ERROR) << "dlclose failed " << dlerror();
@@ -176,7 +176,7 @@ void Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libNam
            std::unique_ptr<void, decltype(dlClose)>{dlopen(libName.c_str(), RTLD_LAZY), dlClose};
            std::unique_ptr<void, decltype(dlClose)>{dlopen(libName.c_str(), RTLD_LAZY), dlClose};
    if (!libHandle) {
    if (!libHandle) {
        LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
        LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
        return;
        return false;
    }
    }


    LOG(INFO) << __func__ << " dlopen lib:" << libName << "\nimpl:" << impl.toString()
    LOG(INFO) << __func__ << " dlopen lib:" << libName << "\nimpl:" << impl.toString()
@@ -186,6 +186,7 @@ void Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libNam
            {impl,
            {impl,
             std::make_tuple(std::move(libHandle),
             std::make_tuple(std::move(libHandle),
                             std::unique_ptr<struct effect_dl_interface_s>(interface), libName)});
                             std::unique_ptr<struct effect_dl_interface_s>(interface), libName)});
    return true;
}
}


void Factory::createIdentityWithConfig(const EffectConfig::LibraryUuid& configLib,
void Factory::createIdentityWithConfig(const EffectConfig::LibraryUuid& configLib,
@@ -201,8 +202,9 @@ void Factory::createIdentityWithConfig(const EffectConfig::LibraryUuid& configLi
        LOG(DEBUG) << __func__ << ": typeUuid " << id.type.toString() << "\nimplUuid "
        LOG(DEBUG) << __func__ << ": typeUuid " << id.type.toString() << "\nimplUuid "
                   << id.uuid.toString() << " proxyUuid "
                   << id.uuid.toString() << " proxyUuid "
                   << (proxyUuid.has_value() ? proxyUuid->toString() : "null");
                   << (proxyUuid.has_value() ? proxyUuid->toString() : "null");
        openEffectLibrary(id.uuid, path->second);
        if (openEffectLibrary(id.uuid, path->second)) {
            mIdentitySet.insert(std::move(id));
            mIdentitySet.insert(std::move(id));
        }
    } else {
    } else {
        LOG(ERROR) << __func__ << ": library " << libName << " not exist!";
        LOG(ERROR) << __func__ << ": library " << libName << " not exist!";
        return;
        return;
+1 −1
Original line number Original line Diff line number Diff line
@@ -101,7 +101,7 @@ class Factory : public BnFactory {


    ndk::ScopedAStatus destroyEffectImpl(const std::shared_ptr<IEffect>& in_handle);
    ndk::ScopedAStatus destroyEffectImpl(const std::shared_ptr<IEffect>& in_handle);
    void cleanupEffectMap();
    void cleanupEffectMap();
    void openEffectLibrary(const ::aidl::android::media::audio::common::AudioUuid& impl,
    bool openEffectLibrary(const ::aidl::android::media::audio::common::AudioUuid& impl,
                           const std::string& libName);
                           const std::string& libName);
    void createIdentityWithConfig(
    void createIdentityWithConfig(
            const EffectConfig::LibraryUuid& configLib,
            const EffectConfig::LibraryUuid& configLib,