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 <audio_effects/effect_downmix.h> 21 22 #include "DownmixContext.h" 23 #include "effect-impl/EffectImpl.h" 24 25 namespace aidl::android::hardware::audio::effect { 26 27 class DownmixImpl final : public EffectImpl { 28 public: 29 static const std::string kEffectName; 30 static const Descriptor kDescriptor; 31 DownmixImpl() = default; ~DownmixImpl()32 ~DownmixImpl() { cleanUp(); } 33 34 ndk::ScopedAStatus getDescriptor(Descriptor* _aidl_return) override; 35 ndk::ScopedAStatus setParameterSpecific(const Parameter::Specific& specific) 36 REQUIRES(mImplMutex) override; 37 ndk::ScopedAStatus getParameterSpecific(const Parameter::Id& id, Parameter::Specific* specific) 38 REQUIRES(mImplMutex) override; 39 IEffect::Status effectProcessImpl(float* in, float* out, int process) 40 REQUIRES(mImplMutex) override; 41 std::shared_ptr<EffectContext> createContext(const Parameter::Common& common) 42 REQUIRES(mImplMutex) override; 43 RetCode releaseContext() REQUIRES(mImplMutex) override; 44 getEffectName()45 std::string getEffectName() override { return kEffectName; } 46 47 // downmix override the process because of different input/output sample size requirement 48 void process() override; 49 50 private: 51 std::shared_ptr<DownmixContext> mContext GUARDED_BY(mImplMutex); 52 ndk::ScopedAStatus getParameterDownmix(const Downmix::Tag& tag, Parameter::Specific* specific) 53 REQUIRES(mImplMutex); 54 }; 55 } // namespace aidl::android::hardware::audio::effect 56