Update libaudiohal with AudioHalVersionInfo
Bug: 261129656
Test: atest VtsHalAudioEffectTargetTest
Flash to Cuttlefish and Panther and check audio.
Change-Id: Ieace37b25dc03d50048b35b1c63b4ec5f39257c8
diff --git a/media/libaudiohal/impl/Android.bp b/media/libaudiohal/impl/Android.bp
index d30883a..bb5601f 100644
--- a/media/libaudiohal/impl/Android.bp
+++ b/media/libaudiohal/impl/Android.bp
@@ -12,13 +12,14 @@
srcs: [
"CoreConversionHelperHidl.cpp",
"DeviceHalHidl.cpp",
+ "DevicesFactoryHalEntry.cpp",
"DevicesFactoryHalHidl.cpp",
"StreamHalHidl.cpp",
],
}
filegroup {
- name: "audio_effect_hal_client_sources",
+ name: "audio_effect_hidl_hal_client_sources",
srcs: [
"EffectBufferHalHidl.cpp",
"EffectConversionHelperHidl.cpp",
@@ -28,6 +29,21 @@
}
cc_defaults {
+ name: "libaudiohal_hidl_default",
+ shared_libs: [
+ "android.hardware.audio.common-util",
+ "android.hidl.allocator@1.0",
+ "android.hidl.memory@1.0",
+ "libaudiohal_deathhandler",
+ "libhidlbase",
+ "libhidlmemory",
+ ],
+ header_libs: [
+ "android.hardware.audio.common.util@all-versions",
+ ]
+}
+
+cc_defaults {
name: "libaudiohal_default",
cflags: [
@@ -37,28 +53,21 @@
"-fvisibility=hidden",
],
shared_libs: [
- "android.hardware.audio.common-util",
- "android.hidl.allocator@1.0",
- "android.hidl.memory@1.0",
+ "audioclient-types-aidl-cpp",
"av-types-aidl-cpp",
"libaudiofoundation",
- "libaudiohal_deathhandler",
"libaudioutils",
"libbase",
"libbinder",
"libcutils",
"libfmq",
"libhardware",
- "libhidlbase",
- "libhidlmemory",
"liblog",
"libmedia_helper",
"libmediautils",
"libutils",
- "audioclient-types-aidl-cpp",
],
header_libs: [
- "android.hardware.audio.common.util@all-versions",
"libaudioclient_headers",
"libaudiohal_headers"
],
@@ -70,11 +79,14 @@
cc_library_shared {
name: "libaudiohal@4.0",
- defaults: ["libaudiohal_default"],
+ defaults: [
+ "libaudiohal_default",
+ "libaudiohal_hidl_default"
+ ],
srcs: [
":audio_core_hal_client_sources",
- ":audio_effect_hal_client_sources",
- "EffectsFactoryHalHidlEntry.cpp",
+ ":audio_effect_hidl_hal_client_sources",
+ "EffectsFactoryHalEntry.cpp",
],
shared_libs: [
"android.hardware.audio.common@4.0",
@@ -93,11 +105,14 @@
cc_library_shared {
name: "libaudiohal@5.0",
- defaults: ["libaudiohal_default"],
+ defaults: [
+ "libaudiohal_default",
+ "libaudiohal_hidl_default"
+ ],
srcs: [
":audio_core_hal_client_sources",
- ":audio_effect_hal_client_sources",
- "EffectsFactoryHalHidlEntry.cpp",
+ ":audio_effect_hidl_hal_client_sources",
+ "EffectsFactoryHalEntry.cpp",
],
shared_libs: [
"android.hardware.audio.common@5.0",
@@ -116,11 +131,14 @@
cc_library_shared {
name: "libaudiohal@6.0",
- defaults: ["libaudiohal_default"],
+ defaults: [
+ "libaudiohal_default",
+ "libaudiohal_hidl_default"
+ ],
srcs: [
":audio_core_hal_client_sources",
- ":audio_effect_hal_client_sources",
- "EffectsFactoryHalHidlEntry.cpp",
+ ":audio_effect_hidl_hal_client_sources",
+ "EffectsFactoryHalEntry.cpp",
],
shared_libs: [
"android.hardware.audio.common@6.0",
@@ -139,9 +157,12 @@
cc_library_static {
name: "libaudiohal.effect@7.0",
- defaults: ["libaudiohal_default"],
+ defaults: [
+ "libaudiohal_default",
+ "libaudiohal_hidl_default"
+ ],
srcs: [
- ":audio_effect_hal_client_sources",
+ ":audio_effect_hidl_hal_client_sources",
],
static_libs: [
"android.hardware.audio.common@7.0",
@@ -158,10 +179,13 @@
cc_library_shared {
name: "libaudiohal@7.0",
- defaults: ["libaudiohal_default"],
+ defaults: [
+ "libaudiohal_default",
+ "libaudiohal_hidl_default"
+ ],
srcs: [
":audio_core_hal_client_sources",
- "EffectsFactoryHalHidlEntry.cpp",
+ "EffectsFactoryHalEntry.cpp",
],
static_libs: [
"android.hardware.audio.common@7.0",
@@ -182,10 +206,13 @@
cc_library_shared {
name: "libaudiohal@7.1",
- defaults: ["libaudiohal_default"],
+ defaults: [
+ "libaudiohal_default",
+ "libaudiohal_hidl_default"
+ ],
srcs: [
":audio_core_hal_client_sources",
- "EffectsFactoryHalHidlEntry.cpp",
+ "EffectsFactoryHalEntry.cpp",
],
static_libs: [
"android.hardware.audio.common@7.0",
@@ -207,3 +234,22 @@
"-include common/all-versions/VersionMacro.h",
]
}
+
+cc_library_shared {
+ name: "libaudiohal@aidl",
+ defaults: [
+ "libaudiohal_default",
+ "latest_android_hardware_audio_common_ndk_shared",
+ "latest_android_hardware_audio_core_ndk_shared",
+ "latest_android_hardware_audio_effect_ndk_shared",
+ ],
+ srcs: [
+ "DevicesFactoryHalEntry.cpp",
+ "DevicesFactoryHalAidl.cpp",
+ "EffectsFactoryHalAidl.cpp",
+ "EffectsFactoryHalEntry.cpp",
+ ],
+ shared_libs: [
+ "libbinder_ndk",
+ ]
+}
\ No newline at end of file
diff --git a/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp b/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
new file mode 100644
index 0000000..29fb558
--- /dev/null
+++ b/media/libaudiohal/impl/DevicesFactoryHalAidl.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 "DevicesFactoryHalAidl"
+//#define LOG_NDEBUG 0
+
+#include <android/binder_manager.h>
+#include <utils/Log.h>
+
+#include "DevicesFactoryHalAidl.h"
+
+using ::android::detail::AudioHalVersionInfo;
+
+namespace android {
+
+DevicesFactoryHalAidl::DevicesFactoryHalAidl(std::shared_ptr<IConfig> iconfig) {
+ ALOG_ASSERT(iconfig != nullptr, "Provided default IConfig service is NULL");
+ mIConfig = std::move(iconfig);
+}
+
+void DevicesFactoryHalAidl::onFirstRef() {
+ ALOGE("%s not implemented yet", __func__);
+}
+
+// Opens a device with the specified name. To close the device, it is
+// necessary to release references to the returned object.
+status_t DevicesFactoryHalAidl::openDevice(const char *name, sp<DeviceHalInterface> *device) {
+ if (name == nullptr || device == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t DevicesFactoryHalAidl::getHalPids(std::vector<pid_t> *pids) {
+ if (pids == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t DevicesFactoryHalAidl::setCallbackOnce(sp<DevicesFactoryHalCallback> callback) {
+ if (callback == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+AudioHalVersionInfo DevicesFactoryHalAidl::getHalVersion() const {
+ int32_t versionNumber = 0;
+ if (mIConfig) {
+ if (!mIConfig->getInterfaceVersion(&versionNumber).isOk()) {
+ ALOGE("%s getInterfaceVersion failed", __func__);
+ } else {
+ ALOGI("%s getInterfaceVersion %d", __func__, versionNumber);
+ }
+ }
+ // AIDL does not have minor version, fill 0 for all versions
+ return AudioHalVersionInfo(AudioHalVersionInfo::Type::AIDL, versionNumber);
+}
+
+// Main entry-point to the shared library.
+extern "C" __attribute__((visibility("default"))) void* createIDevicesFactoryImpl() {
+ auto service = IConfig::fromBinder(
+ ndk::SpAIBinder(AServiceManager_waitForService(IConfig::descriptor)));
+ return service ? new DevicesFactoryHalAidl(service) : nullptr;
+}
+
+} // namespace android
diff --git a/media/libaudiohal/impl/DevicesFactoryHalAidl.h b/media/libaudiohal/impl/DevicesFactoryHalAidl.h
new file mode 100644
index 0000000..f4812af
--- /dev/null
+++ b/media/libaudiohal/impl/DevicesFactoryHalAidl.h
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <aidl/android/hardware/audio/core/IConfig.h>
+#include <media/audiohal/DevicesFactoryHalInterface.h>
+#include <utils/RefBase.h>
+
+using namespace ::aidl::android::hardware::audio::core;
+
+namespace android {
+
+class DevicesFactoryHalAidl : public DevicesFactoryHalInterface
+{
+ public:
+ explicit DevicesFactoryHalAidl(std::shared_ptr<IConfig> iConfig);
+ void onFirstRef() override;
+
+ // Opens a device with the specified name. To close the device, it is
+ // necessary to release references to the returned object.
+ status_t openDevice(const char *name, sp<DeviceHalInterface> *device) override;
+
+ status_t getHalPids(std::vector<pid_t> *pids) override;
+
+ status_t setCallbackOnce(sp<DevicesFactoryHalCallback> callback) override;
+
+ android::detail::AudioHalVersionInfo getHalVersion() const override;
+
+ private:
+ std::shared_ptr<IConfig> mIConfig;
+ virtual ~DevicesFactoryHalAidl() = default;
+};
+
+} // namespace android
diff --git a/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp b/media/libaudiohal/impl/DevicesFactoryHalEntry.cpp
similarity index 74%
copy from media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp
copy to media/libaudiohal/impl/DevicesFactoryHalEntry.cpp
index 2c6f2c6..5bf6d89 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp
+++ b/media/libaudiohal/impl/DevicesFactoryHalEntry.cpp
@@ -14,8 +14,10 @@
* limitations under the License.
*/
-extern "C" void* createIEffectsFactoryImpl();
+#include "android/media/AudioHalVersion.h"
-extern "C" __attribute__((visibility("default"))) void* createIEffectsFactory() {
- return createIEffectsFactoryImpl();
+extern "C" void* createIDevicesFactoryImpl();
+
+extern "C" __attribute__((visibility("default"))) void* createIDevicesFactory() {
+ return createIDevicesFactoryImpl();
}
diff --git a/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp b/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp
index 4069a6b..9f06f83 100644
--- a/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp
+++ b/media/libaudiohal/impl/DevicesFactoryHalHidl.cpp
@@ -29,6 +29,7 @@
#include "DeviceHalHidl.h"
#include "DevicesFactoryHalHidl.h"
+using ::android::detail::AudioHalVersionInfo;
using ::android::hardware::audio::CPP_VERSION::IDevice;
using ::android::hardware::audio::CORE_TYPES_CPP_VERSION::Result;
using ::android::hardware::Return;
@@ -226,8 +227,13 @@
return mDeviceFactories;
}
+
+AudioHalVersionInfo DevicesFactoryHalHidl::getHalVersion() const {
+ return AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, MAJOR_VERSION, MINOR_VERSION);
+}
+
// Main entry-point to the shared library.
-extern "C" __attribute__((visibility("default"))) void* createIDevicesFactory() {
+extern "C" __attribute__((visibility("default"))) void* createIDevicesFactoryImpl() {
auto service = hardware::audio::CPP_VERSION::IDevicesFactory::getService();
return service ? new DevicesFactoryHalHidl(service) : nullptr;
}
diff --git a/media/libaudiohal/impl/DevicesFactoryHalHidl.h b/media/libaudiohal/impl/DevicesFactoryHalHidl.h
index ffd229d..5294728 100644
--- a/media/libaudiohal/impl/DevicesFactoryHalHidl.h
+++ b/media/libaudiohal/impl/DevicesFactoryHalHidl.h
@@ -45,7 +45,7 @@
status_t setCallbackOnce(sp<DevicesFactoryHalCallback> callback) override;
- float getHalVersion() const override { return MAJOR_VERSION + (float)MINOR_VERSION / 10; }
+ android::detail::AudioHalVersionInfo getHalVersion() const override;
private:
friend class ServiceNotificationListener;
diff --git a/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp b/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp
new file mode 100644
index 0000000..7aec859
--- /dev/null
+++ b/media/libaudiohal/impl/EffectsFactoryHalAidl.cpp
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+
+#include <random>
+#define LOG_TAG "EffectsFactoryHalAidl"
+//#define LOG_NDEBUG 0
+
+#include <aidl/android/hardware/audio/effect/IFactory.h>
+#include <android/binder_manager.h>
+#include <utils/Log.h>
+
+#include "EffectsFactoryHalAidl.h"
+
+using aidl::android::hardware::audio::effect::IFactory;
+using android::detail::AudioHalVersionInfo;
+
+namespace android {
+namespace effect {
+
+EffectsFactoryHalAidl::EffectsFactoryHalAidl(std::shared_ptr<IFactory> effectsFactory) {
+ ALOG_ASSERT(effectsFactory != nullptr, "Provided IEffectsFactory service is NULL");
+ mEffectsFactory = effectsFactory;
+}
+
+status_t EffectsFactoryHalAidl::queryNumberEffects(uint32_t *pNumEffects) {
+ if (pNumEffects == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::getDescriptor(uint32_t index, effect_descriptor_t* pDescriptor) {
+ if (index < 0 || pDescriptor == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::getDescriptor(const effect_uuid_t* pEffectUuid,
+ effect_descriptor_t* pDescriptor) {
+ if (pEffectUuid == nullptr || pDescriptor == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::getDescriptors(const effect_uuid_t* pEffectType,
+ std::vector<effect_descriptor_t>* descriptors) {
+ if (pEffectType == nullptr || descriptors == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::createEffect(const effect_uuid_t* pEffectUuid, int32_t sessionId,
+ int32_t ioId, int32_t deviceId __unused,
+ sp<EffectHalInterface>* effect) {
+ if (pEffectUuid == nullptr || effect == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet %d %d", __func__, sessionId, ioId);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::dumpEffects(int fd) {
+ ALOGE("%s not implemented yet, fd %d", __func__, fd);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) {
+ if (size <= 0 || buffer == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+status_t EffectsFactoryHalAidl::mirrorBuffer(void* external, size_t size,
+ sp<EffectBufferHalInterface>* buffer) {
+ if (external == nullptr || size <= 0 || buffer == nullptr) {
+ return BAD_VALUE;
+ }
+ ALOGE("%s not implemented yet", __func__);
+ return INVALID_OPERATION;
+}
+
+AudioHalVersionInfo EffectsFactoryHalAidl::getHalVersion() const {
+ int32_t versionNumber = 0;
+ if (mEffectsFactory) {
+ if (!mEffectsFactory->getInterfaceVersion(&versionNumber).isOk()) {
+ ALOGE("%s getInterfaceVersion failed", __func__);
+ } else {
+ ALOGI("%s getInterfaceVersion %d", __func__, versionNumber);
+ }
+ }
+ // AIDL does not have minor version, fill 0 for all versions
+ return AudioHalVersionInfo(AudioHalVersionInfo::Type::AIDL, versionNumber);
+}
+
+} // namespace effect
+
+// 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 EffectsFactoryHalEntry.cpp.
+extern "C" void* createIEffectsFactoryImpl() {
+ auto factory = IFactory::fromBinder(
+ ndk::SpAIBinder(AServiceManager_waitForService(IFactory::descriptor)));
+ return factory ? new effect::EffectsFactoryHalAidl(factory) : nullptr;
+}
+
+} // namespace android
diff --git a/media/libaudiohal/impl/EffectsFactoryHalAidl.h b/media/libaudiohal/impl/EffectsFactoryHalAidl.h
new file mode 100644
index 0000000..d6b5684
--- /dev/null
+++ b/media/libaudiohal/impl/EffectsFactoryHalAidl.h
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include <media/audiohal/EffectsFactoryHalInterface.h>
+
+namespace android {
+namespace effect {
+
+using namespace aidl::android::hardware::audio::effect;
+
+class EffectsFactoryHalAidl final : public EffectsFactoryHalInterface {
+ public:
+ explicit EffectsFactoryHalAidl(std::shared_ptr<IFactory> effectsFactory);
+
+ // Returns the number of different effects in all loaded libraries.
+ status_t queryNumberEffects(uint32_t *pNumEffects) override;
+
+ // Returns a descriptor of the next available effect.
+ status_t getDescriptor(uint32_t index, effect_descriptor_t* pDescriptor) override;
+
+ status_t getDescriptor(const effect_uuid_t* pEffectUuid,
+ effect_descriptor_t* pDescriptor) override;
+
+ status_t getDescriptors(const effect_uuid_t* pEffectType,
+ std::vector<effect_descriptor_t>* descriptors) override;
+
+ // Creates an effect engine of the specified type.
+ // To release the effect engine, it is necessary to release references
+ // to the returned effect object.
+ status_t createEffect(const effect_uuid_t* pEffectUuid, int32_t sessionId, int32_t ioId,
+ int32_t deviceId, sp<EffectHalInterface>* effect) override;
+
+ status_t dumpEffects(int fd) override;
+
+ status_t allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) override;
+ status_t mirrorBuffer(void* external, size_t size,
+ sp<EffectBufferHalInterface>* buffer) override;
+
+ android::detail::AudioHalVersionInfo getHalVersion() const override;
+
+ private:
+ std::shared_ptr<IFactory> mEffectsFactory;
+ virtual ~EffectsFactoryHalAidl() = default;
+};
+
+} // namespace effect
+} // namespace android
diff --git a/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp b/media/libaudiohal/impl/EffectsFactoryHalEntry.cpp
similarity index 94%
rename from media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp
rename to media/libaudiohal/impl/EffectsFactoryHalEntry.cpp
index 2c6f2c6..f6ad99a 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalHidlEntry.cpp
+++ b/media/libaudiohal/impl/EffectsFactoryHalEntry.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include "android/media/AudioHalVersion.h"
+
extern "C" void* createIEffectsFactoryImpl();
extern "C" __attribute__((visibility("default"))) void* createIEffectsFactory() {
diff --git a/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp b/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp
index 3470380..172ebdf 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp
+++ b/media/libaudiohal/impl/EffectsFactoryHalHidl.cpp
@@ -31,6 +31,9 @@
#include "EffectHalHidl.h"
#include "EffectsFactoryHalHidl.h"
+#include "android/media/AudioHalVersion.h"
+
+using ::android::detail::AudioHalVersionInfo;
using ::android::hardware::audio::common::CPP_VERSION::implementation::UuidUtils;
using ::android::hardware::audio::effect::CPP_VERSION::implementation::EffectUtils;
using ::android::hardware::Return;
@@ -77,7 +80,7 @@
EffectsFactoryHalHidl::EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory)
: EffectConversionHelperHidl("EffectsFactory"), mCache(new EffectDescriptorCache) {
ALOG_ASSERT(effectsFactory != nullptr, "Provided IEffectsFactory service is NULL");
- mEffectsFactory = effectsFactory;
+ mEffectsFactory = std::move(effectsFactory);
}
status_t EffectsFactoryHalHidl::queryNumberEffects(uint32_t *pNumEffects) {
@@ -221,11 +224,15 @@
return EffectBufferHalHidl::mirror(external, size, buffer);
}
+AudioHalVersionInfo EffectsFactoryHalHidl::getHalVersion() const {
+ return AudioHalVersionInfo(AudioHalVersionInfo::Type::HIDL, MAJOR_VERSION, MINOR_VERSION);
+}
+
} // namespace effect
// 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.
+// the shared library. See EffectsFactoryHalEntry.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 7ccddc6..9875154 100644
--- a/media/libaudiohal/impl/EffectsFactoryHalHidl.h
+++ b/media/libaudiohal/impl/EffectsFactoryHalHidl.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef ANDROID_HARDWARE_EFFECTS_FACTORY_HAL_HIDL_H
-#define ANDROID_HARDWARE_EFFECTS_FACTORY_HAL_HIDL_H
+#pragma once
#include <memory>
@@ -32,39 +31,37 @@
class EffectDescriptorCache;
-class EffectsFactoryHalHidl : public EffectsFactoryHalInterface, public EffectConversionHelperHidl
-{
+class EffectsFactoryHalHidl final : public EffectsFactoryHalInterface,
+ public EffectConversionHelperHidl {
public:
EffectsFactoryHalHidl(sp<IEffectsFactory> effectsFactory);
// Returns the number of different effects in all loaded libraries.
- virtual status_t queryNumberEffects(uint32_t *pNumEffects);
+ status_t queryNumberEffects(uint32_t *pNumEffects) override;
// Returns a descriptor of the next available effect.
- virtual status_t getDescriptor(uint32_t index,
- effect_descriptor_t *pDescriptor);
+ status_t getDescriptor(uint32_t index, effect_descriptor_t* pDescriptor) override;
- virtual status_t getDescriptor(const effect_uuid_t *pEffectUuid,
- effect_descriptor_t *pDescriptor);
+ status_t getDescriptor(const effect_uuid_t* pEffectUuid,
+ effect_descriptor_t* pDescriptor) override;
- virtual status_t getDescriptors(const effect_uuid_t *pEffectType,
- std::vector<effect_descriptor_t> *descriptors);
+ status_t getDescriptors(const effect_uuid_t* pEffectType,
+ std::vector<effect_descriptor_t>* descriptors) override;
// Creates an effect engine of the specified type.
// To release the effect engine, it is necessary to release references
// to the returned effect object.
- virtual status_t createEffect(const effect_uuid_t *pEffectUuid,
- int32_t sessionId, int32_t ioId, int32_t deviceId,
- sp<EffectHalInterface> *effect);
+ status_t createEffect(const effect_uuid_t* pEffectUuid, int32_t sessionId, int32_t ioId,
+ int32_t deviceId, sp<EffectHalInterface>* effect) override;
- virtual status_t dumpEffects(int fd);
-
- virtual float getHalVersion() { return MAJOR_VERSION + (float)MINOR_VERSION / 10; }
+ status_t dumpEffects(int fd) override;
status_t allocateBuffer(size_t size, sp<EffectBufferHalInterface>* buffer) override;
status_t mirrorBuffer(void* external, size_t size,
sp<EffectBufferHalInterface>* buffer) override;
+ android::detail::AudioHalVersionInfo getHalVersion() const override;
+
private:
sp<IEffectsFactory> mEffectsFactory;
std::unique_ptr<EffectDescriptorCache> mCache;
@@ -72,5 +69,3 @@
} // namespace effect
} // namespace android
-
-#endif // ANDROID_HARDWARE_EFFECTS_FACTORY_HAL_HIDL_H