AIDL effect: Minimal example implementation am: c23916b96f
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2198792 Change-Id: I7cf14ef2cfd2a7ea88aaf0c005d903bd51c5f7f9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
082f06b5f0
9 changed files with 272 additions and 0 deletions
|
@ -51,3 +51,45 @@ cc_binary {
|
|||
],
|
||||
srcs: ["main.cpp"],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "libaudioeffectserviceexampleimpl",
|
||||
vendor: true,
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"android.media.audio.common.types-V1-ndk",
|
||||
"android.hardware.audio.effect-V1-ndk",
|
||||
],
|
||||
export_include_dirs: ["include"],
|
||||
srcs: [
|
||||
"EffectFactory.cpp",
|
||||
],
|
||||
visibility: [
|
||||
":__subpackages__",
|
||||
],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.audio.effect.service-aidl.example",
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.audio.effect.service-aidl.example.rc"],
|
||||
vintf_fragments: ["android.hardware.audio.effect.service-aidl.xml"],
|
||||
vendor: true,
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"android.media.audio.common.types-V1-ndk",
|
||||
"android.hardware.audio.effect-V1-ndk",
|
||||
],
|
||||
static_libs: [
|
||||
"libaudioeffectserviceexampleimpl",
|
||||
],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
"-Wthread-safety",
|
||||
],
|
||||
srcs: ["EffectMain.cpp"],
|
||||
}
|
||||
|
|
59
audio/aidl/default/EffectFactory.cpp
Normal file
59
audio/aidl/default/EffectFactory.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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 "AHAL_EffectFactory"
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include "effectFactory-impl/EffectFactory.h"
|
||||
#include "equalizer-impl/Equalizer.h"
|
||||
#include "visualizer-impl/Visualizer.h"
|
||||
|
||||
using aidl::android::media::audio::common::AudioUuid;
|
||||
|
||||
namespace aidl::android::hardware::audio::effect {
|
||||
|
||||
Factory::Factory() {
|
||||
// TODO: implement this with xml parser on audio_effect.xml, and filter with optional
|
||||
// parameters.
|
||||
Descriptor::Identity id;
|
||||
id.type = {static_cast<int32_t>(0x0bed4300),
|
||||
0xddd6,
|
||||
0x11db,
|
||||
0x8f34,
|
||||
{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
|
||||
id.uuid = EqualizerUUID;
|
||||
mIdentityList.push_back(id);
|
||||
id.type = {static_cast<int32_t>(0xd3467faa),
|
||||
0xacc7,
|
||||
0x4d34,
|
||||
0xacaf,
|
||||
{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
|
||||
id.uuid = VisualizerUUID;
|
||||
mIdentityList.push_back(id);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Factory::queryEffects(const std::optional<AudioUuid>& in_type,
|
||||
const std::optional<AudioUuid>& in_instance,
|
||||
std::vector<Descriptor::Identity>* _aidl_return) {
|
||||
std::copy_if(mIdentityList.begin(), mIdentityList.end(), std::back_inserter(*_aidl_return),
|
||||
[&](auto& desc) {
|
||||
return (!in_type.has_value() || in_type.value() == desc.type) &&
|
||||
(!in_instance.has_value() || in_instance.value() == desc.uuid);
|
||||
});
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::audio::effect
|
38
audio/aidl/default/EffectMain.cpp
Normal file
38
audio/aidl/default/EffectMain.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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 "effectFactory-impl/EffectFactory.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
int main() {
|
||||
// This is a debug implementation, always enable debug logging.
|
||||
android::base::SetMinimumLogSeverity(::android::base::DEBUG);
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(16);
|
||||
|
||||
auto effectFactory =
|
||||
ndk::SharedRefBase::make<aidl::android::hardware::audio::effect::Factory>();
|
||||
std::string serviceName = std::string() + effectFactory->descriptor + "/default";
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(effectFactory->asBinder().get(), serviceName.c_str());
|
||||
CHECK_EQ(STATUS_OK, status);
|
||||
LOG(DEBUG) << __func__ << ": effectFactoryName:" << serviceName;
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
service vendor.audio-effect-hal-aidl /vendor/bin/hw/android.hardware.audio.effect.service-aidl.example
|
||||
class hal
|
||||
user audioserver
|
||||
# media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
|
||||
group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock context_hub
|
||||
capabilities BLOCK_SUSPEND
|
||||
ioprio rt 4
|
||||
task_profiles ProcessCapacityHigh HighPerformance
|
||||
onrestart restart audioserver
|
|
@ -0,0 +1,7 @@
|
|||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.audio.effect</name>
|
||||
<version>1</version>
|
||||
<fqname>IFactory/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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 <optional>
|
||||
#include <vector>
|
||||
|
||||
#include <aidl/android/hardware/audio/effect/BnFactory.h>
|
||||
|
||||
namespace aidl::android::hardware::audio::effect {
|
||||
|
||||
class Factory : public BnFactory {
|
||||
public:
|
||||
Factory();
|
||||
/**
|
||||
* @brief Get identity of all effects supported by the device, with the optional filter by type
|
||||
* and/or by instance UUID.
|
||||
*
|
||||
* @param in_type Type UUID.
|
||||
* @param in_instance Instance UUID.
|
||||
* @param out_descriptor List of identities .
|
||||
* @return ndk::ScopedAStatus
|
||||
*/
|
||||
ndk::ScopedAStatus queryEffects(
|
||||
const std::optional<::aidl::android::media::audio::common::AudioUuid>& in_type,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioUuid>& in_instance,
|
||||
std::vector<Descriptor::Identity>* out_descriptor) override;
|
||||
|
||||
private:
|
||||
// List of effect descriptors supported by the devices.
|
||||
std::vector<Descriptor::Identity> mIdentityList;
|
||||
};
|
||||
} // namespace aidl::android::hardware::audio::effect
|
31
audio/aidl/default/include/equalizer-impl/Equalizer.h
Normal file
31
audio/aidl/default/include/equalizer-impl/Equalizer.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 <cstdlib>
|
||||
|
||||
namespace aidl::android::hardware::audio::effect {
|
||||
|
||||
// Equalizer implementation UUID.
|
||||
static const ::aidl::android::media::audio::common::AudioUuid EqualizerUUID = {
|
||||
static_cast<int32_t>(0xce772f20),
|
||||
0x847d,
|
||||
0x11df,
|
||||
0xbb17,
|
||||
{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
|
||||
|
||||
} // namespace aidl::android::hardware::audio::effect
|
31
audio/aidl/default/include/visualizer-impl/Visualizer.h
Normal file
31
audio/aidl/default/include/visualizer-impl/Visualizer.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* 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 <cstdlib>
|
||||
|
||||
namespace aidl::android::hardware::audio::effect {
|
||||
|
||||
// Visualizer implementation UUID.
|
||||
static const ::aidl::android::media::audio::common::AudioUuid VisualizerUUID = {
|
||||
static_cast<int32_t>(0x1d4033c0),
|
||||
0x8557,
|
||||
0x11df,
|
||||
0x9f2d,
|
||||
{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
|
||||
|
||||
} // namespace aidl::android::hardware::audio::effect
|
|
@ -37,6 +37,14 @@
|
|||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="false">
|
||||
<name>android.hardware.audio.effect</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IFactory</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="aidl" optional="true">
|
||||
<name>android.hardware.authsecret</name>
|
||||
<version>1</version>
|
||||
|
|
Loading…
Reference in a new issue