1 /* 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 26 namespace aidl::android::hardware::audio::effect { 27 28 class DownmixSwContext final : public EffectContext { 29 public: DownmixSwContext(int statusDepth,const Parameter::Common & common)30 DownmixSwContext(int statusDepth, const Parameter::Common& common) 31 : EffectContext(statusDepth, common) { 32 LOG(DEBUG) << __func__; 33 } 34 setDmType(Downmix::Type type)35 RetCode setDmType(Downmix::Type type) { 36 // TODO : Add implementation to apply new type 37 mType = type; 38 return RetCode::SUCCESS; 39 } getDmType()40 Downmix::Type getDmType() const { return mType; } 41 42 private: 43 Downmix::Type mType = Downmix::Type::STRIP; 44 }; 45 46 class DownmixSw final : public EffectImpl { 47 public: 48 static const std::string kEffectName; 49 static const Capability kCapability; 50 static const Descriptor kDescriptor; DownmixSw()51 DownmixSw() { LOG(DEBUG) << __func__; } ~DownmixSw()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) 59 REQUIRES(mImplMutex) override; 60 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific) 61 REQUIRES(mImplMutex) override; 62 63 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) 64 REQUIRES(mImplMutex) override; 65 RetCode releaseContext() REQUIRES(mImplMutex) override; 66 getEffectName()67 std::string getEffectName() override { return kEffectName; }; 68 IEffect::Status effectProcessImpl(float* in, float* out, int sample) 69 REQUIRES(mImplMutex) override; 70 71 private: 72 std::shared_ptr<DownmixSwContext> mContext GUARDED_BY(mImplMutex); 73 74 ndk::ScopedAStatus getParameterDownmix(const Downmix::Tag& tag, Parameter::Specific* specific) 75 REQUIRES(mImplMutex); 76 }; 77 } // namespace aidl::android::hardware::audio::effect 78