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

Commit 52ba4dc1 authored by Shunkai Yao's avatar Shunkai Yao
Browse files

Effect AIDL: remove the shared_lib dependency for example binary

They will be dlopen so no need to add the shared_lib dependency.
But we need to add them as PRODUCT_PACKAGES in base_vendor.mk

Bug: 258124419
Test: build and boot cuttlefish, change effect lib path in Android.bp
and audio_effects_config.xml and bootup.

Change-Id: Ia3b9bef9b5ed86921d80adcc0ce2296f50939370
parent 8c91779b
Loading
Loading
Loading
Loading
+0 −16
Original line number Original line Diff line number Diff line
@@ -152,23 +152,7 @@ cc_binary {
    vintf_fragments: ["android.hardware.audio.effect.service-aidl.xml"],
    vintf_fragments: ["android.hardware.audio.effect.service-aidl.xml"],
    defaults: ["aidlaudioeffectservice_defaults"],
    defaults: ["aidlaudioeffectservice_defaults"],
    shared_libs: [
    shared_libs: [
        "libaecsw",
        "libagcsw",
        "libbassboostsw",
        "libbundleaidl",
        "libdownmixaidl",
        "libdynamicsprocessingaidl",
        "libenvreverbsw",
        "libequalizersw",
        "libhapticgeneratoraidl",
        "libloudnessenhanceraidl",
        "libnssw",
        "libpresetreverbsw",
        "libreverbaidl",
        "libtinyxml2",
        "libtinyxml2",
        "libvirtualizersw",
        "libvisualizeraidl",
        "libvolumesw",
    ],
    ],
    srcs: [
    srcs: [
        "EffectConfig.cpp",
        "EffectConfig.cpp",
+18 −2
Original line number Original line Diff line number Diff line
@@ -79,14 +79,30 @@ std::vector<std::reference_wrapper<const tinyxml2::XMLElement>> EffectConfig::ge
    return children;
    return children;
}
}


bool EffectConfig::resolveLibrary(const std::string& path, std::string* resolvedPath) {
    for (auto* libraryDirectory : kEffectLibPath) {
        std::string candidatePath = std::string(libraryDirectory) + '/' + path;
        if (access(candidatePath.c_str(), R_OK) == 0) {
            *resolvedPath = std::move(candidatePath);
            return true;
        }
    }
    return false;
}

bool EffectConfig::parseLibrary(const tinyxml2::XMLElement& xml) {
bool EffectConfig::parseLibrary(const tinyxml2::XMLElement& xml) {
    const char* name = xml.Attribute("name");
    const char* name = xml.Attribute("name");
    RETURN_VALUE_IF(!name, false, "noNameAttribute");
    RETURN_VALUE_IF(!name, false, "noNameAttribute");
    const char* path = xml.Attribute("path");
    const char* path = xml.Attribute("path");
    RETURN_VALUE_IF(!path, false, "noPathAttribute");
    RETURN_VALUE_IF(!path, false, "noPathAttribute");


    mLibraryMap[name] = path;
    std::string resolvedPath;
    LOG(DEBUG) << __func__ << " " << name << " : " << path;
    if (!resolveLibrary(path, &resolvedPath)) {
        LOG(ERROR) << __func__ << " can't find " << path;
        return false;
    }
    mLibraryMap[name] = resolvedPath;
    LOG(DEBUG) << __func__ << " " << name << " : " << resolvedPath;
    return true;
    return true;
}
}


+6 −6
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;
}
}


bool Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libName) {
bool Factory::openEffectLibrary(const AudioUuid& impl, const std::string& path) {
    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();
@@ -173,19 +173,19 @@ bool Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libNam
    };
    };


    auto libHandle =
    auto libHandle =
            std::unique_ptr<void, decltype(dlClose)>{dlopen(libName.c_str(), RTLD_LAZY), dlClose};
            std::unique_ptr<void, decltype(dlClose)>{dlopen(path.c_str(), RTLD_LAZY), dlClose};
    if (!libHandle) {
    if (!libHandle) {
        LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
        LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
        return false;
        return false;
    }
    }


    LOG(INFO) << __func__ << " dlopen lib:" << libName << "\nimpl:" << impl.toString()
    LOG(INFO) << __func__ << " dlopen lib:" << path << "\nimpl:" << impl.toString()
              << "\nhandle:" << libHandle;
              << "\nhandle:" << libHandle;
    auto interface = new effect_dl_interface_s{nullptr, nullptr, nullptr};
    auto interface = new effect_dl_interface_s{nullptr, nullptr, nullptr};
    mEffectLibMap.insert(
    mEffectLibMap.insert(
            {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), path)});
    return true;
    return true;
}
}


@@ -199,8 +199,8 @@ void Factory::createIdentityWithConfig(const EffectConfig::LibraryUuid& configLi
        id.type = typeUuid;
        id.type = typeUuid;
        id.uuid = configLib.uuid;
        id.uuid = configLib.uuid;
        id.proxy = proxyUuid;
        id.proxy = proxyUuid;
        LOG(DEBUG) << __func__ << ": typeUuid " << id.type.toString() << "\nimplUuid "
        LOG(DEBUG) << __func__ << " loading lib " << path->second << ": typeUuid "
                   << id.uuid.toString() << " proxyUuid "
                   << id.type.toString() << "\nimplUuid " << id.uuid.toString() << " proxyUuid "
                   << (proxyUuid.has_value() ? proxyUuid->toString() : "null");
                   << (proxyUuid.has_value() ? proxyUuid->toString() : "null");
        if (openEffectLibrary(id.uuid, path->second)) {
        if (openEffectLibrary(id.uuid, path->second)) {
            mIdentitySet.insert(std::move(id));
            mIdentitySet.insert(std::move(id));
+1 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ cc_library_shared {
        "AcousticEchoCancelerSw.cpp",
        "AcousticEchoCancelerSw.cpp",
        ":effectCommonFile",
        ":effectCommonFile",
    ],
    ],
    relative_install_path: "soundfx",
    visibility: [
    visibility: [
        "//hardware/interfaces/audio/aidl/default",
        "//hardware/interfaces/audio/aidl/default",
    ],
    ],
+1 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ cc_library_shared {
        "AutomaticGainControlSw.cpp",
        "AutomaticGainControlSw.cpp",
        ":effectCommonFile",
        ":effectCommonFile",
    ],
    ],
    relative_install_path: "soundfx",
    visibility: [
    visibility: [
        "//hardware/interfaces/audio/aidl/default",
        "//hardware/interfaces/audio/aidl/default",
    ],
    ],
Loading