mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:23:37 +00:00
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
This commit is contained in:
@@ -152,23 +152,7 @@ cc_binary {
|
||||
vintf_fragments: ["android.hardware.audio.effect.service-aidl.xml"],
|
||||
defaults: ["aidlaudioeffectservice_defaults"],
|
||||
shared_libs: [
|
||||
"libaecsw",
|
||||
"libagcsw",
|
||||
"libbassboostsw",
|
||||
"libbundleaidl",
|
||||
"libdownmixaidl",
|
||||
"libdynamicsprocessingaidl",
|
||||
"libenvreverbsw",
|
||||
"libequalizersw",
|
||||
"libhapticgeneratoraidl",
|
||||
"libloudnessenhanceraidl",
|
||||
"libnssw",
|
||||
"libpresetreverbsw",
|
||||
"libreverbaidl",
|
||||
"libtinyxml2",
|
||||
"libvirtualizersw",
|
||||
"libvisualizeraidl",
|
||||
"libvolumesw",
|
||||
],
|
||||
srcs: [
|
||||
"EffectConfig.cpp",
|
||||
|
||||
@@ -79,14 +79,30 @@ std::vector<std::reference_wrapper<const tinyxml2::XMLElement>> EffectConfig::ge
|
||||
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) {
|
||||
const char* name = xml.Attribute("name");
|
||||
RETURN_VALUE_IF(!name, false, "noNameAttribute");
|
||||
const char* path = xml.Attribute("path");
|
||||
RETURN_VALUE_IF(!path, false, "noPathAttribute");
|
||||
|
||||
mLibraryMap[name] = path;
|
||||
LOG(DEBUG) << __func__ << " " << name << " : " << path;
|
||||
std::string resolvedPath;
|
||||
if (!resolveLibrary(path, &resolvedPath)) {
|
||||
LOG(ERROR) << __func__ << " can't find " << path;
|
||||
return false;
|
||||
}
|
||||
mLibraryMap[name] = resolvedPath;
|
||||
LOG(DEBUG) << __func__ << " " << name << " : " << resolvedPath;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ ndk::ScopedAStatus Factory::destroyEffect(const std::shared_ptr<IEffect>& in_han
|
||||
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 {
|
||||
if (handle && dlclose(handle)) {
|
||||
LOG(ERROR) << "dlclose failed " << dlerror();
|
||||
@@ -173,19 +173,19 @@ bool Factory::openEffectLibrary(const AudioUuid& impl, const std::string& libNam
|
||||
};
|
||||
|
||||
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) {
|
||||
LOG(ERROR) << __func__ << ": dlopen failed, err: " << dlerror();
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG(INFO) << __func__ << " dlopen lib:" << libName << "\nimpl:" << impl.toString()
|
||||
LOG(INFO) << __func__ << " dlopen lib:" << path << "\nimpl:" << impl.toString()
|
||||
<< "\nhandle:" << libHandle;
|
||||
auto interface = new effect_dl_interface_s{nullptr, nullptr, nullptr};
|
||||
mEffectLibMap.insert(
|
||||
{impl,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -199,8 +199,8 @@ void Factory::createIdentityWithConfig(const EffectConfig::LibraryUuid& configLi
|
||||
id.type = typeUuid;
|
||||
id.uuid = configLib.uuid;
|
||||
id.proxy = proxyUuid;
|
||||
LOG(DEBUG) << __func__ << ": typeUuid " << id.type.toString() << "\nimplUuid "
|
||||
<< id.uuid.toString() << " proxyUuid "
|
||||
LOG(DEBUG) << __func__ << " loading lib " << path->second << ": typeUuid "
|
||||
<< id.type.toString() << "\nimplUuid " << id.uuid.toString() << " proxyUuid "
|
||||
<< (proxyUuid.has_value() ? proxyUuid->toString() : "null");
|
||||
if (openEffectLibrary(id.uuid, path->second)) {
|
||||
mIdentitySet.insert(std::move(id));
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"AcousticEchoCancelerSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"AutomaticGainControlSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"BassBoostSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"DownmixSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"DynamicsProcessingSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"EnvReverbSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"EqualizerSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"HapticGeneratorSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -63,6 +63,13 @@ class EffectConfig {
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr const char* kEffectLibPath[] =
|
||||
#ifdef __LP64__
|
||||
{"/odm/lib64/soundfx", "/vendor/lib64/soundfx", "/system/lib64/soundfx"};
|
||||
#else
|
||||
{"/odm/lib/soundfx", "/vendor/lib/soundfx", "/system/lib/soundfx"};
|
||||
#endif
|
||||
|
||||
int mSkippedElements;
|
||||
/* Parsed Libraries result */
|
||||
std::unordered_map<std::string, std::string> mLibraryMap;
|
||||
@@ -91,6 +98,8 @@ class EffectConfig {
|
||||
|
||||
const char* dump(const tinyxml2::XMLElement& element,
|
||||
tinyxml2::XMLPrinter&& printer = {}) const;
|
||||
|
||||
bool resolveLibrary(const std::string& path, std::string* resolvedPath);
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::audio::effect
|
||||
|
||||
@@ -102,7 +102,7 @@ class Factory : public BnFactory {
|
||||
ndk::ScopedAStatus destroyEffectImpl(const std::shared_ptr<IEffect>& in_handle);
|
||||
void cleanupEffectMap();
|
||||
bool openEffectLibrary(const ::aidl::android::media::audio::common::AudioUuid& impl,
|
||||
const std::string& libName);
|
||||
const std::string& path);
|
||||
void createIdentityWithConfig(
|
||||
const EffectConfig::LibraryUuid& configLib,
|
||||
const ::aidl::android::media::audio::common::AudioUuid& typeUuid,
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"LoudnessEnhancerSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"NoiseSuppressionSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"PresetReverbSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"VirtualizerSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"VisualizerSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
@@ -34,6 +34,7 @@ cc_library_shared {
|
||||
"VolumeSw.cpp",
|
||||
":effectCommonFile",
|
||||
],
|
||||
relative_install_path: "soundfx",
|
||||
visibility: [
|
||||
"//hardware/interfaces/audio/aidl/default",
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user