diff options
author | Mikhail Naganov <mnaganov@google.com> | 2020-08-11 23:23:16 +0000 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2020-09-28 23:18:37 +0000 |
commit | c9e1607de4c5f4854bc58ee9fdf45d16010cc476 (patch) | |
tree | f51282daf2e19340923532aa5027845e31dadabf /audio/common/7.0/example/EffectsFactory.cpp | |
parent | 108e702dc736e40a371619af91c47a059daf095c (diff) |
audio: Add example HAL implementation
This is partial implementation of the example V7.0 audio HAL
which passes VTS tests. Note that the 'core' part
of the HAL (IDevice/IStream) isn't implemented yet.
It passes VTS because it doesn't provide any devices
(modules) and the audio HAL isn't the 'default' instance.
Bug: 142480271
Test: atest VtsHalAudioV7_0TargetTest
atest VtsHalAudioEffectV7_0TargetTest
Change-Id: Ie3dd62c5db1cdb5534df4dd7f326c4c8776bf3c4
Diffstat (limited to 'audio/common/7.0/example/EffectsFactory.cpp')
-rw-r--r-- | audio/common/7.0/example/EffectsFactory.cpp | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/audio/common/7.0/example/EffectsFactory.cpp b/audio/common/7.0/example/EffectsFactory.cpp new file mode 100644 index 0000000000..7d333ae040 --- /dev/null +++ b/audio/common/7.0/example/EffectsFactory.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2020 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 "EffectsFactory7.0" +#include <log/log.h> + +#include "EffectsFactory.h" +#include "EqualizerEffect.h" +#include "LoudnessEnhancerEffect.h" + +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using namespace ::android::hardware::audio::common::V7_0; + +namespace android::hardware::audio::effect::V7_0::implementation { + +Return<void> EffectsFactory::getAllDescriptors(getAllDescriptors_cb _hidl_cb) { + hidl_vec<EffectDescriptor> descriptors; + descriptors.resize(2); + descriptors[0] = EqualizerEffect::getDescriptor(); + descriptors[1] = LoudnessEnhancerEffect::getDescriptor(); + _hidl_cb(Result::OK, descriptors); + return Void(); +} + +Return<void> EffectsFactory::getDescriptor(const Uuid& uuid, getDescriptor_cb _hidl_cb) { + if (auto desc = EqualizerEffect::getDescriptor(); uuid == desc.type || uuid == desc.uuid) { + _hidl_cb(Result::OK, desc); + } else if (auto desc = LoudnessEnhancerEffect::getDescriptor(); + uuid == desc.type || uuid == desc.uuid) { + _hidl_cb(Result::OK, desc); + } else { + _hidl_cb(Result::INVALID_ARGUMENTS, EffectDescriptor{}); + } + return Void(); +} + +Return<void> EffectsFactory::createEffect(const Uuid& uuid, int32_t session, int32_t ioHandle, + int32_t device, createEffect_cb _hidl_cb) { + (void)session; + (void)ioHandle; + (void)device; + if (auto desc = EqualizerEffect::getDescriptor(); uuid == desc.type || uuid == desc.uuid) { + _hidl_cb(Result::OK, new EqualizerEffect(), 0); + } else if (auto desc = LoudnessEnhancerEffect::getDescriptor(); + uuid == desc.type || uuid == desc.uuid) { + _hidl_cb(Result::OK, new LoudnessEnhancerEffect(), 0); + } else { + _hidl_cb(Result::INVALID_ARGUMENTS, nullptr, 0); + } + return Void(); +} + +Return<void> EffectsFactory::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) { + (void)fd; + (void)options; + return Void(); +} + +} // namespace android::hardware::audio::effect::V7_0::implementation |