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
diff --git a/audio/aidl/default/Android.bp b/audio/aidl/default/Android.bp
index 95043f7..856f83f 100644
--- a/audio/aidl/default/Android.bp
+++ b/audio/aidl/default/Android.bp
@@ -152,23 +152,7 @@
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",
diff --git a/audio/aidl/default/EffectConfig.cpp b/audio/aidl/default/EffectConfig.cpp
index e1427ec..c030b7a 100644
--- a/audio/aidl/default/EffectConfig.cpp
+++ b/audio/aidl/default/EffectConfig.cpp
@@ -79,14 +79,30 @@
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;
}
diff --git a/audio/aidl/default/EffectFactory.cpp b/audio/aidl/default/EffectFactory.cpp
index 5cd87fd..638fa7f 100644
--- a/audio/aidl/default/EffectFactory.cpp
+++ b/audio/aidl/default/EffectFactory.cpp
@@ -165,7 +165,7 @@
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 @@
};
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 @@
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));
diff --git a/audio/aidl/default/acousticEchoCanceler/Android.bp b/audio/aidl/default/acousticEchoCanceler/Android.bp
index b2e2682..bfb7212 100644
--- a/audio/aidl/default/acousticEchoCanceler/Android.bp
+++ b/audio/aidl/default/acousticEchoCanceler/Android.bp
@@ -34,6 +34,7 @@
"AcousticEchoCancelerSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/automaticGainControl/Android.bp b/audio/aidl/default/automaticGainControl/Android.bp
index 4899b39..17d6416 100644
--- a/audio/aidl/default/automaticGainControl/Android.bp
+++ b/audio/aidl/default/automaticGainControl/Android.bp
@@ -34,6 +34,7 @@
"AutomaticGainControlSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/bassboost/Android.bp b/audio/aidl/default/bassboost/Android.bp
index f22eb95..82b2f20 100644
--- a/audio/aidl/default/bassboost/Android.bp
+++ b/audio/aidl/default/bassboost/Android.bp
@@ -34,6 +34,7 @@
"BassBoostSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/downmix/Android.bp b/audio/aidl/default/downmix/Android.bp
index 230b2d8..6d15cdb 100644
--- a/audio/aidl/default/downmix/Android.bp
+++ b/audio/aidl/default/downmix/Android.bp
@@ -34,6 +34,7 @@
"DownmixSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/dynamicProcessing/Android.bp b/audio/aidl/default/dynamicProcessing/Android.bp
index 3697ba3..1c0312d 100644
--- a/audio/aidl/default/dynamicProcessing/Android.bp
+++ b/audio/aidl/default/dynamicProcessing/Android.bp
@@ -34,6 +34,7 @@
"DynamicsProcessingSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/envReverb/Android.bp b/audio/aidl/default/envReverb/Android.bp
index c239ee5..dd4219a 100644
--- a/audio/aidl/default/envReverb/Android.bp
+++ b/audio/aidl/default/envReverb/Android.bp
@@ -34,6 +34,7 @@
"EnvReverbSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/equalizer/Android.bp b/audio/aidl/default/equalizer/Android.bp
index 8de6b1a..3610563 100644
--- a/audio/aidl/default/equalizer/Android.bp
+++ b/audio/aidl/default/equalizer/Android.bp
@@ -34,6 +34,7 @@
"EqualizerSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/hapticGenerator/Android.bp b/audio/aidl/default/hapticGenerator/Android.bp
index a632130..0df9a94 100644
--- a/audio/aidl/default/hapticGenerator/Android.bp
+++ b/audio/aidl/default/hapticGenerator/Android.bp
@@ -34,6 +34,7 @@
"HapticGeneratorSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/include/effectFactory-impl/EffectConfig.h b/audio/aidl/default/include/effectFactory-impl/EffectConfig.h
index 2b904f5..c499811 100644
--- a/audio/aidl/default/include/effectFactory-impl/EffectConfig.h
+++ b/audio/aidl/default/include/effectFactory-impl/EffectConfig.h
@@ -63,6 +63,13 @@
}
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 @@
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
diff --git a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
index b32ec56..fc9ef02 100644
--- a/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
+++ b/audio/aidl/default/include/effectFactory-impl/EffectFactory.h
@@ -102,7 +102,7 @@
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,
diff --git a/audio/aidl/default/loudnessEnhancer/Android.bp b/audio/aidl/default/loudnessEnhancer/Android.bp
index 3a0ac73..89a72fe 100644
--- a/audio/aidl/default/loudnessEnhancer/Android.bp
+++ b/audio/aidl/default/loudnessEnhancer/Android.bp
@@ -34,6 +34,7 @@
"LoudnessEnhancerSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/noiseSuppression/Android.bp b/audio/aidl/default/noiseSuppression/Android.bp
index 581d4bf..dad3d49 100644
--- a/audio/aidl/default/noiseSuppression/Android.bp
+++ b/audio/aidl/default/noiseSuppression/Android.bp
@@ -34,6 +34,7 @@
"NoiseSuppressionSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/presetReverb/Android.bp b/audio/aidl/default/presetReverb/Android.bp
index 4148511..18bdd17 100644
--- a/audio/aidl/default/presetReverb/Android.bp
+++ b/audio/aidl/default/presetReverb/Android.bp
@@ -34,6 +34,7 @@
"PresetReverbSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/virtualizer/Android.bp b/audio/aidl/default/virtualizer/Android.bp
index ba38f5c..ed0199d 100644
--- a/audio/aidl/default/virtualizer/Android.bp
+++ b/audio/aidl/default/virtualizer/Android.bp
@@ -34,6 +34,7 @@
"VirtualizerSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/visualizer/Android.bp b/audio/aidl/default/visualizer/Android.bp
index 5041be8..091daa2 100644
--- a/audio/aidl/default/visualizer/Android.bp
+++ b/audio/aidl/default/visualizer/Android.bp
@@ -34,6 +34,7 @@
"VisualizerSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],
diff --git a/audio/aidl/default/volume/Android.bp b/audio/aidl/default/volume/Android.bp
index 505ee67..418bb8d 100644
--- a/audio/aidl/default/volume/Android.bp
+++ b/audio/aidl/default/volume/Android.bp
@@ -34,6 +34,7 @@
"VolumeSw.cpp",
":effectCommonFile",
],
+ relative_install_path: "soundfx",
visibility: [
"//hardware/interfaces/audio/aidl/default",
],