blob: 3f8a09b16ca1c599276077d9c81ba777efdbc25d [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"
Sham Rathod40f55bd2022-11-14 14:24:49 +053025
26namespace aidl::android::hardware::audio::effect {
27
28class DownmixSwContext final : public EffectContext {
29 public:
30 DownmixSwContext(int statusDepth, const Parameter::Common& common)
31 : EffectContext(statusDepth, common) {
32 LOG(DEBUG) << __func__;
33 }
34
35 RetCode setDmType(Downmix::Type type) {
36 // TODO : Add implementation to apply new type
37 mType = type;
38 return RetCode::SUCCESS;
39 }
40 Downmix::Type getDmType() const { return mType; }
41
42 private:
43 Downmix::Type mType = Downmix::Type::STRIP;
44};
45
46class DownmixSw final : public EffectImpl {
47 public:
48 static const std::string kEffectName;
Shunkai Yao87811022023-02-13 17:40:37 +000049 static const Capability kCapability;
Sham Rathod40f55bd2022-11-14 14:24:49 +053050 static const Descriptor kDescriptor;
51 DownmixSw() { LOG(DEBUG) << __func__; }
52 ~DownmixSw() {
53 cleanUp();
54 LOG(DEBUG) << __func__;
55 }
56
57 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override;
58 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) override;
59 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id,
60 Parameter::Specific* specific) override;
61
62 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) override;
63 std::shared_ptr<EffectContext> getContext() override;
64 RetCode releaseContext() override;
65
66 std::string getEffectName() override { return kEffectName; };
67 IEffect::Status effectProcessImpl(float* in, float* out, int sample) override;
68
69 private:
70 std::shared_ptr<DownmixSwContext> mContext;
71
72 ndk::ScopedAStatus getParameterDownmix(const Downmix::Tag& tag, Parameter::Specific* specific);
73};
74} // namespace aidl::android::hardware::audio::effect