blob: 51546c1b5630a64a2c2daedc306946144f84dbdf [file] [log] [blame]
Sham Rathod40f55bd2022-11-14 14:24:49 +05301/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <aidl/android/hardware/audio/effect/BnEffect.h>
20#include <fmq/AidlMessageQueue.h>
21#include <cstdlib>
22#include <memory>
23
24#include "effect-impl/EffectImpl.h"
25#include "effect-impl/EffectUUID.h"
26
27namespace aidl::android::hardware::audio::effect {
28
29class DownmixSwContext final : public EffectContext {
30 public:
31 DownmixSwContext(int statusDepth, const Parameter::Common& common)
32 : EffectContext(statusDepth, common) {
33 LOG(DEBUG) << __func__;
34 }
35
36 RetCode setDmType(Downmix::Type type) {
37 // TODO : Add implementation to apply new type
38 mType = type;
39 return RetCode::SUCCESS;
40 }
41 Downmix::Type getDmType() const { return mType; }
42
43 private:
44 Downmix::Type mType = Downmix::Type::STRIP;
45};
46
47class DownmixSw final : public EffectImpl {
48 public:
49 static const std::string kEffectName;
50 static const Downmix::Capability kCapability;
51 static const Descriptor kDescriptor;
52 DownmixSw() { LOG(DEBUG) << __func__; }
53 ~DownmixSw() {
54 cleanUp();
55 LOG(DEBUG) << __func__;
56 }
57
58 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
59 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
60 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
61 Parameter::Specific* specific) override;
62
63 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
64 std::shared_ptr<EffectContext> getContext() override;
65 RetCode releaseContext() override;
66
67 std::string getEffectName() override { return kEffectName; };
68 IEffect::Status effectProcessImpl(float* in, float* out, int sample) override;
69
70 private:
71 std::shared_ptr<DownmixSwContext> mContext;
72
73 ndk::ScopedAStatus getParameterDownmix(const Downmix::Tag& tag, Parameter::Specific* specific);
74};
75} // namespace aidl::android::hardware::audio::effect