libaudiohal: Optimize loading for minor version upgrades
Make libaudiohal@7.1 to contain clients for core HAL
V7.1 and effect HAL V7.0. This is to avoid loading
both libaudiohal@7.1 (for core) and libaudiohal@7.0
(for effects).
Update the loader to figure out maximum minor version
and only load the library for that version.
Implemented proper conversion for the Result type
from the a.h.audio.effect library.
Bug: 219730472
Test: adb shell dumpsys meminfo
Change-Id: I44dd6c77505f6bbf8897e10b083e99e36730b43d
diff --git a/media/libaudiohal/impl/Android.bp b/media/libaudiohal/impl/Android.bp
index 4002fbf..d30883a 100644
--- a/media/libaudiohal/impl/Android.bp
+++ b/media/libaudiohal/impl/Android.bp
@@ -10,6 +10,7 @@
filegroup {
name: "audio_core_hal_client_sources",
srcs: [
+ "CoreConversionHelperHidl.cpp",
"DeviceHalHidl.cpp",
"DevicesFactoryHalHidl.cpp",
"StreamHalHidl.cpp",
@@ -20,6 +21,7 @@
name: "audio_effect_hal_client_sources",
srcs: [
"EffectBufferHalHidl.cpp",
+ "EffectConversionHelperHidl.cpp",
"EffectHalHidl.cpp",
"EffectsFactoryHalHidl.cpp",
],
@@ -28,10 +30,6 @@
cc_defaults {
name: "libaudiohal_default",
- srcs: [
- "ConversionHelperHidl.cpp",
- ],
-
cflags: [
"-Wall",
"-Wextra",
@@ -76,6 +74,7 @@
srcs: [
":audio_core_hal_client_sources",
":audio_effect_hal_client_sources",
+ "EffectsFactoryHalHidlEntry.cpp",
],
shared_libs: [
"android.hardware.audio.common@4.0",
@@ -98,6 +97,7 @@
srcs: [
":audio_core_hal_client_sources",
":audio_effect_hal_client_sources",
+ "EffectsFactoryHalHidlEntry.cpp",
],
shared_libs: [
"android.hardware.audio.common@5.0",
@@ -120,6 +120,7 @@
srcs: [
":audio_core_hal_client_sources",
":audio_effect_hal_client_sources",
+ "EffectsFactoryHalHidlEntry.cpp",
],
shared_libs: [
"android.hardware.audio.common@6.0",
@@ -136,12 +137,31 @@
]
}
+cc_library_static {
+ name: "libaudiohal.effect@7.0",
+ defaults: ["libaudiohal_default"],
+ srcs: [
+ ":audio_effect_hal_client_sources",
+ ],
+ static_libs: [
+ "android.hardware.audio.common@7.0",
+ "android.hardware.audio.common@7.0-util",
+ "android.hardware.audio.effect@7.0",
+ "android.hardware.audio.effect@7.0-util",
+ ],
+ cflags: [
+ "-DMAJOR_VERSION=7",
+ "-DMINOR_VERSION=0",
+ "-include common/all-versions/VersionMacro.h",
+ ]
+}
+
cc_library_shared {
name: "libaudiohal@7.0",
defaults: ["libaudiohal_default"],
srcs: [
":audio_core_hal_client_sources",
- ":audio_effect_hal_client_sources",
+ "EffectsFactoryHalHidlEntry.cpp",
],
static_libs: [
"android.hardware.audio.common@7.0",
@@ -151,6 +171,7 @@
"android.hardware.audio.effect@7.0-util",
"android.hardware.audio@7.0",
"android.hardware.audio@7.0-util",
+ "libaudiohal.effect@7.0",
],
cflags: [
"-DMAJOR_VERSION=7",
@@ -164,14 +185,19 @@
defaults: ["libaudiohal_default"],
srcs: [
":audio_core_hal_client_sources",
+ "EffectsFactoryHalHidlEntry.cpp",
],
static_libs: [
"android.hardware.audio.common@7.0",
+ "android.hardware.audio.common@7.0-util",
"android.hardware.audio.common@7.1-enums",
"android.hardware.audio.common@7.1-util",
+ "android.hardware.audio.effect@7.0",
+ "android.hardware.audio.effect@7.0-util",
"android.hardware.audio@7.0",
"android.hardware.audio@7.1",
"android.hardware.audio@7.1-util",
+ "libaudiohal.effect@7.0",
],
cflags: [
"-DMAJOR_VERSION=7",
diff --git a/media/libaudiohal/impl/ConversionHelperHidl.h b/media/libaudiohal/impl/ConversionHelperHidl.h
index 3163cbb..6e2c831 100644
--- a/media/libaudiohal/impl/ConversionHelperHidl.h
+++ b/media/libaudiohal/impl/ConversionHelperHidl.h
@@ -17,33 +17,25 @@
#ifndef ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_H
#define ANDROID_HARDWARE_CONVERSION_HELPER_HIDL_H
-#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h)
+#include <functional>
+
#include <hidl/HidlSupport.h>
#include <system/audio.h>
-#include <utils/String8.h>
-#include <utils/String16.h>
-#include <utils/Vector.h>
-
-using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::ParameterValue;
-using CoreResult = ::android::hardware::audio::CORE_TYPES_CPP_VERSION::Result;
-
-using ::android::hardware::Return;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
namespace android {
+template<typename HalResult>
class ConversionHelperHidl {
protected:
- static status_t keysFromHal(const String8& keys, hidl_vec<hidl_string> *hidlKeys);
- static status_t parametersFromHal(const String8& kvPairs, hidl_vec<ParameterValue> *hidlParams);
- static void parametersToHal(const hidl_vec<ParameterValue>& parameters, String8 *values);
- static void argsFromHal(const Vector<String16>& args, hidl_vec<hidl_string> *hidlArgs);
+ using HalResultConverter = std::function<status_t(const HalResult&)>;
+ const std::string mClassName;
- ConversionHelperHidl(std::string_view className);
+ ConversionHelperHidl(std::string_view className, HalResultConverter resultConv)
+ : mClassName(className), mResultConverter(resultConv) {}
template<typename R, typename T>
- status_t processReturn(const char* funcName, const Return<R>& ret, T *retval) {
+ status_t processReturn(const char* funcName,
+ const ::android::hardware::Return<R>& ret, T *retval) {
if (ret.isOk()) {
// This way it also works for enum class to unscoped enum conversion.
*retval = static_cast<T>(static_cast<R>(ret));
@@ -53,27 +45,28 @@
}
template<typename T>
- status_t processReturn(const char* funcName, const Return<T>& ret) {
+ status_t processReturn(const char* funcName, const ::android::hardware::Return<T>& ret) {
if (!ret.isOk()) {
emitError(funcName, ret.description().c_str());
}
return ret.isOk() ? OK : FAILED_TRANSACTION;
}
- status_t processReturn(const char* funcName, const Return<CoreResult>& ret) {
+ status_t processReturn(const char* funcName,
+ const ::android::hardware::Return<HalResult>& ret) {
if (!ret.isOk()) {
emitError(funcName, ret.description().c_str());
}
- return ret.isOk() ? analyzeResult(ret) : FAILED_TRANSACTION;
+ return ret.isOk() ? mResultConverter(ret) : FAILED_TRANSACTION;
}
template<typename T>
status_t processReturn(
- const char* funcName, const Return<T>& ret, CoreResult retval) {
+ const char* funcName, const ::android::hardware::Return<T>& ret, HalResult retval) {
if (!ret.isOk()) {
emitError(funcName, ret.description().c_str());
}
- return ret.isOk() ? analyzeResult(retval) : FAILED_TRANSACTION;
+ return ret.isOk() ? mResultConverter(retval) : FAILED_TRANSACTION;
}
const std::string& getClassName() const {
@@ -81,11 +74,11 @@
}
private:
- const std::string mClassName;
+ HalResultConverter mResultConverter;
- static status_t analyzeResult(const CoreResult& result);
-
- void emitError(const char* funcName, const char* description);
+ void emitError(const char* funcName, const char* description) {
+ ALOGE("%s %p %s: %s (from rpc)", mClassName.c_str(), this, funcName, description);
+ }
};
} // namespace android
diff --git a/media/libaudiohal/impl/ConversionHelperHidl.cpp b/media/libaudiohal/impl/CoreConversionHelperHidl.cpp
similarity index 86%
rename from media/libaudiohal/impl/ConversionHelperHidl.cpp
rename to media/libaudiohal/impl/CoreConversionHelperHidl.cpp
index a1668ca..2ac8a42 100644
--- a/media/libaudiohal/impl/ConversionHelperHidl.cpp
+++ b/media/libaudiohal/impl/CoreConversionHelperHidl.cpp
@@ -21,7 +21,7 @@
#include <media/AudioParameter.h>
#include <utils/Log.h>
-#include "ConversionHelperHidl.h"
+#include "CoreConversionHelperHidl.h"
namespace android {
@@ -29,7 +29,8 @@
using namespace ::android::hardware::audio::CORE_TYPES_CPP_VERSION;
// static
-status_t ConversionHelperHidl::keysFromHal(const String8& keys, hidl_vec<hidl_string> *hidlKeys) {
+status_t CoreConversionHelperHidl::keysFromHal(
+ const String8& keys, hidl_vec<hidl_string> *hidlKeys) {
AudioParameter halKeys(keys);
if (halKeys.size() == 0) return BAD_VALUE;
hidlKeys->resize(halKeys.size());
@@ -74,7 +75,7 @@
}
// static
-status_t ConversionHelperHidl::parametersFromHal(
+status_t CoreConversionHelperHidl::parametersFromHal(
const String8& kvPairs, hidl_vec<ParameterValue> *hidlParams) {
AudioParameter params(kvPairs);
if (params.size() == 0) return BAD_VALUE;
@@ -90,7 +91,7 @@
}
// static
-void ConversionHelperHidl::parametersToHal(
+void CoreConversionHelperHidl::parametersToHal(
const hidl_vec<ParameterValue>& parameters, String8 *values) {
AudioParameter params;
for (size_t i = 0; i < parameters.size(); ++i) {
@@ -99,12 +100,11 @@
values->setTo(params.toString());
}
-ConversionHelperHidl::ConversionHelperHidl(std::string_view className)
- : mClassName(className.begin(), className.end()) {
-}
+CoreConversionHelperHidl::CoreConversionHelperHidl(std::string_view className)
+ : ConversionHelperHidl<CoreResult>(className, analyzeResult) {}
// static
-void ConversionHelperHidl::argsFromHal(
+void CoreConversionHelperHidl::argsFromHal(
const Vector<String16>& args, hidl_vec<hidl_string> *hidlArgs) {
hidlArgs->resize(args.size());
for (size_t i = 0; i < args.size(); ++i) {
@@ -113,19 +113,15 @@
}
// static
-status_t ConversionHelperHidl::analyzeResult(const Result& result) {
+status_t CoreConversionHelperHidl::analyzeResult(const CoreResult& result) {
switch (result) {
case Result::OK: return OK;
case Result::INVALID_ARGUMENTS: return BAD_VALUE;
case Result::INVALID_STATE: return NOT_ENOUGH_DATA;
case Result::NOT_INITIALIZED: return NO_INIT;
case Result::NOT_SUPPORTED: return INVALID_OPERATION;
- default: return NO_INIT;
}
-}
-
-void ConversionHelperHidl::emitError(const char* funcName, const char* description) {
- ALOGE("%s %p %s: %s (from rpc)", mClassName.c_str(), this, funcName, description);
+ return NO_INIT;
}
} // namespace android
diff --git a/media/libaudiohal/impl/CoreConversionHelperHidl.h b/media/libaudiohal/impl/CoreConversionHelperHidl.h
new file mode 100644
index 0000000..a4d76f3
--- /dev/null
+++ b/media/libaudiohal/impl/CoreConversionHelperHidl.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_CORE_CONVERSION_HELPER_HIDL_H
+#define ANDROID_HARDWARE_CORE_CONVERSION_HELPER_HIDL_H
+
+#include "ConversionHelperHidl.h"
+
+#include PATH(android/hardware/audio/CORE_TYPES_FILE_VERSION/types.h)
+#include <utils/String8.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+
+using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::ParameterValue;
+using CoreResult = ::android::hardware::audio::CORE_TYPES_CPP_VERSION::Result;
+
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+
+namespace android {
+
+class CoreConversionHelperHidl : public ConversionHelperHidl<CoreResult> {
+ protected:
+ static status_t keysFromHal(const String8& keys, hidl_vec<hidl_string> *hidlKeys);
+ static status_t parametersFromHal(const String8& kvPairs, hidl_vec<ParameterValue> *hidlParams);
+ static void parametersToHal(const hidl_vec<ParameterValue>& parameters, String8 *values);
+ static void argsFromHal(const Vector<String16>& args, hidl_vec<hidl_string> *hidlArgs);
+
+ CoreConversionHelperHidl(std::string_view className);
+
+ private:
+ static status_t analyzeResult(const CoreResult& result);
+};
+
+} // namespace android
+
+#endif // ANDROID_HARDWARE_CORE_CONVERSION_HELPER_HIDL_H
diff --git a/media/libaudiohal/impl/DeviceHalHidl.cpp b/media/libaudiohal/impl/DeviceHalHidl.cpp
index 7fa1d45..0cdf621 100644
--- a/media/libaudiohal/impl/DeviceHalHidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalHidl.cpp
@@ -50,12 +50,12 @@
mediautils::makeTimeCheckStatsForClassMethod(getClassName(), __func__)
DeviceHalHidl::DeviceHalHidl(const sp<::android::hardware::audio::CPP_VERSION::IDevice>& device)
- : ConversionHelperHidl("DeviceHalHidl"), mDevice(device) {
+ : CoreConversionHelperHidl("DeviceHalHidl"), mDevice(device) {
}
DeviceHalHidl::DeviceHalHidl(
const sp<::android::hardware::audio::CPP_VERSION::IPrimaryDevice>& device)
- : ConversionHelperHidl("DeviceHalHidl"),
+ : CoreConversionHelperHidl("DeviceHalHidl"),
#if MAJOR_VERSION <= 6 || (MAJOR_VERSION == 7 && MINOR_VERSION == 0)
mDevice(device),
#endif
diff --git a/media/libaudiohal/impl/DeviceHalHidl.h b/media/libaudiohal/impl/DeviceHalHidl.h
index 8a97a55..f6519b6 100644
--- a/media/libaudiohal/impl/DeviceHalHidl.h
+++ b/media/libaudiohal/impl/DeviceHalHidl.h
@@ -22,11 +22,11 @@
#include <media/audiohal/DeviceHalInterface.h>
#include <media/audiohal/EffectHalInterface.h>
-#include "ConversionHelperHidl.h"
+#include "CoreConversionHelperHidl.h"
namespace android {
-class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
+class DeviceHalHidl : public DeviceHalInterface, public CoreConversionHelperHidl
{
public:
// Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
diff --git a/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp b/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp
index 8f3c907..4069a6b 100644
--- a/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp
+++ b/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp
@@ -26,7 +26,6 @@
#include <media/audiohal/hidl/HalDeathHandler.h>
#include <utils/Log.h>
-#include "ConversionHelperHidl.h"
#include "DeviceHalHidl.h"
#include "DevicesFactoryHalHidl.h"
diff --git a/media/libaudiohal/impl/EffectBufferHalHidl.cpp b/media/libaudiohal/impl/EffectBufferHalHidl.cpp
index 65297af..9d5f72e 100644
--- a/media/libaudiohal/impl/EffectBufferHalHidl.cpp
+++ b/media/libaudiohal/impl/EffectBufferHalHidl.cpp
@@ -23,7 +23,6 @@
#include <hidlmemory/mapping.h>
#include <utils/Log.h>
-#include "ConversionHelperHidl.h"
#include "EffectBufferHalHidl.h"
using ::android::hardware::Return;
diff --git a/media/libaudiohal/impl/EffectConversionHelperHidl.cpp b/media/libaudiohal/impl/EffectConversionHelperHidl.cpp
new file mode 100644
index 0000000..9e4f79c
--- /dev/null
+++ b/media/libaudiohal/impl/EffectConversionHelperHidl.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "HalHidl"
+#include <utils/Log.h>
+
+#include "EffectConversionHelperHidl.h"
+
+namespace android {
+
+EffectConversionHelperHidl::EffectConversionHelperHidl(std::string_view className)
+ : ConversionHelperHidl<EffectResult>(className, analyzeResult) {
+}
+
+// static
+status_t EffectConversionHelperHidl::analyzeResult(const EffectResult& result) {
+ switch (result) {
+ case EffectResult::OK: return OK;
+ case EffectResult::INVALID_ARGUMENTS: return BAD_VALUE;
+ case EffectResult::INVALID_STATE: return NOT_ENOUGH_DATA;
+ case EffectResult::NOT_INITIALIZED: return NO_INIT;
+ case EffectResult::NOT_SUPPORTED: return INVALID_OPERATION;
+ case EffectResult::RESULT_TOO_BIG: return NO_MEMORY;
+ }
+ return NO_INIT;
+}
+
+} // namespace android
diff --git a/media/libaudiohal/impl/EffectConversionHelperHidl.h b/media/libaudiohal/impl/EffectConversionHelperHidl.h
new file mode 100644
index 0000000..4371d12
--- /dev/null
+++ b/media/libaudiohal/impl/EffectConversionHelperHidl.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_HARDWARE_EFFECT_CONVERSION_HELPER_HIDL_H
+#define ANDROID_HARDWARE_EFFECT_CONVERSION_HELPER_HIDL_H
+
+#include "ConversionHelperHidl.h"
+
+#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h)
+
+using EffectResult = ::android::hardware::audio::effect::CPP_VERSION::Result;
+
+namespace android {
+
+class EffectConversionHelperHidl : public ConversionHelperHidl<EffectResult> {
+ protected:
+ static status_t analyzeResult(const EffectResult& result);
+
+ EffectConversionHelperHidl(std::string_view className);
+};
+
+} // namespace android
+
+#endif // ANDROID_HARDWARE_EFFECT_CONVERSION_HELPER_HIDL_H
diff --git a/media/libaudiohal/impl/EffectHalHidl.cpp b/media/libaudiohal/impl/EffectHalHidl.cpp
index 1bb1e5f..f46a953 100644
--- a/media/libaudiohal/impl/EffectHalHidl.cpp
+++ b/media/libaudiohal/impl/EffectHalHidl.cpp
@@ -41,7 +41,8 @@
using namespace ::android::hardware::audio::effect::CPP_VERSION;
EffectHalHidl::EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId)
- : mEffect(effect), mEffectId(effectId), mBuffersChanged(true), mEfGroup(nullptr) {
+ : EffectConversionHelperHidl("Effect"),
+ mEffect(effect), mEffectId(effectId), mBuffersChanged(true), mEfGroup(nullptr) {
effect_descriptor_t halDescriptor{};
if (EffectHalHidl::getDescriptor(&halDescriptor) == NO_ERROR) {
mIsInput = (halDescriptor.flags & EFFECT_FLAG_TYPE_PRE_PROC) == EFFECT_FLAG_TYPE_PRE_PROC;
@@ -59,19 +60,6 @@
}
}
-// static
-status_t EffectHalHidl::analyzeResult(const Result& result) {
- switch (result) {
- case Result::OK: return OK;
- case Result::INVALID_ARGUMENTS: return BAD_VALUE;
- case Result::INVALID_STATE: return NOT_ENOUGH_DATA;
- case Result::NOT_INITIALIZED: return NO_INIT;
- case Result::NOT_SUPPORTED: return INVALID_OPERATION;
- case Result::RESULT_TOO_BIG: return NO_MEMORY;
- default: return NO_INIT;
- }
-}
-
status_t EffectHalHidl::setInBuffer(const sp<EffectBufferHalInterface>& buffer) {
if (!mBuffersChanged) {
if (buffer.get() == nullptr || mInBuffer.get() == nullptr) {
diff --git a/media/libaudiohal/impl/EffectHalHidl.h b/media/libaudiohal/impl/EffectHalHidl.h
index 07745db..e139768 100644
--- a/media/libaudiohal/impl/EffectHalHidl.h
+++ b/media/libaudiohal/impl/EffectHalHidl.h
@@ -23,6 +23,8 @@
#include <fmq/MessageQueue.h>
#include <system/audio_effect.h>
+#include "EffectConversionHelperHidl.h"
+
using ::android::hardware::EventFlag;
using ::android::hardware::MessageQueue;
@@ -31,7 +33,7 @@
using namespace ::android::hardware::audio::effect::CPP_VERSION;
-class EffectHalHidl : public EffectHalInterface
+class EffectHalHidl : public EffectHalInterface, public EffectConversionHelperHidl
{
public:
// Set the input buffer.
@@ -77,8 +79,6 @@
EventFlag* mEfGroup;
bool mIsInput = false;
- static status_t analyzeResult(const Result& result);
-
// Can not be constructed directly by clients.
EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId);
diff --git a/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp b/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp
index 90954b2..d7217fc 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp
+++ b/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp
@@ -21,8 +21,9 @@
#include <UuidUtils.h>
#include <util/EffectUtils.h>
+#include <utils/Log.h>
-#include "ConversionHelperHidl.h"
+#include "EffectConversionHelperHidl.h"
#include "EffectBufferHalHidl.h"
#include "EffectHalHidl.h"
#include "EffectsFactoryHalHidl.h"
@@ -38,7 +39,7 @@
using namespace ::android::hardware::audio::effect::CPP_VERSION;
EffectsFactoryHalHidl::EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory)
- : ConversionHelperHidl("EffectsFactory") {
+ : EffectConversionHelperHidl("EffectsFactory") {
ALOG_ASSERT(effectsFactory != nullptr, "Provided IEffectsFactory service is NULL");
mEffectsFactory = effectsFactory;
}
@@ -205,7 +206,10 @@
} // namespace effect
-extern "C" __attribute__((visibility("default"))) void* createIEffectsFactory() {
+// When a shared library is built from a static library, even explicit
+// exports from a static library are optimized out unless actually used by
+// the shared library. See EffectsFactoryHalHidlEntry.cpp.
+extern "C" void* createIEffectsFactoryImpl() {
auto service = hardware::audio::effect::CPP_VERSION::IEffectsFactory::getService();
return service ? new effect::EffectsFactoryHalHidl(service) : nullptr;
}
diff --git a/media/libaudiohal/impl/EffectsFactoryHalHidl.h b/media/libaudiohal/impl/EffectsFactoryHalHidl.h
index 7491133..e1882e1 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalHidl.h
+++ b/media/libaudiohal/impl/EffectsFactoryHalHidl.h
@@ -20,16 +20,15 @@
#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h)
#include <media/audiohal/EffectsFactoryHalInterface.h>
-#include "ConversionHelperHidl.h"
+#include "EffectConversionHelperHidl.h"
namespace android {
namespace effect {
using ::android::hardware::hidl_vec;
-using ::android::ConversionHelperHidl;
using namespace ::android::hardware::audio::effect::CPP_VERSION;
-class EffectsFactoryHalHidl : public EffectsFactoryHalInterface, public ConversionHelperHidl
+class EffectsFactoryHalHidl : public EffectsFactoryHalInterface, public EffectConversionHelperHidl
{
public:
EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory);
diff --git a/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp b/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp
new file mode 100644
index 0000000..2c6f2c6
--- /dev/null
+++ b/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+extern "C" void* createIEffectsFactoryImpl();
+
+extern "C" __attribute__((visibility("default"))) void* createIEffectsFactory() {
+ return createIEffectsFactoryImpl();
+}
diff --git a/media/libaudiohal/impl/StreamHalHidl.cpp b/media/libaudiohal/impl/StreamHalHidl.cpp
index 77c2da0..021ec51 100644
--- a/media/libaudiohal/impl/StreamHalHidl.cpp
+++ b/media/libaudiohal/impl/StreamHalHidl.cpp
@@ -50,7 +50,7 @@
mediautils::makeTimeCheckStatsForClassMethod(getClassName(), __func__)
StreamHalHidl::StreamHalHidl(std::string_view className, IStream *stream)
- : ConversionHelperHidl(className),
+ : CoreConversionHelperHidl(className),
mStream(stream),
mHalThreadPriority(HAL_THREAD_PRIORITY_DEFAULT),
mCachedBufferSize(0){
diff --git a/media/libaudiohal/impl/StreamHalHidl.h b/media/libaudiohal/impl/StreamHalHidl.h
index b5ecfd1..54fbefe 100644
--- a/media/libaudiohal/impl/StreamHalHidl.h
+++ b/media/libaudiohal/impl/StreamHalHidl.h
@@ -28,7 +28,7 @@
#include <media/audiohal/StreamHalInterface.h>
#include <mediautils/Synchronization.h>
-#include "ConversionHelperHidl.h"
+#include "CoreConversionHelperHidl.h"
#include "StreamPowerLog.h"
using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::IStream;
@@ -45,7 +45,7 @@
class DeviceHalHidl;
-class StreamHalHidl : public virtual StreamHalInterface, public ConversionHelperHidl
+class StreamHalHidl : public virtual StreamHalInterface, public CoreConversionHelperHidl
{
public:
// Return size of input/output buffer in bytes for this stream - eg. 4800.