1 /* 2 * Copyright (C) 2016 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 #ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H 18 #define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H 19 20 #include <system/audio_effects/effect_ns.h> 21 22 #include <android/hardware/audio/effect/2.0/INoiseSuppressionEffect.h> 23 #include <hidl/Status.h> 24 25 #include <hidl/MQDescriptor.h> 26 27 #include "Effect.h" 28 29 namespace android { 30 namespace hardware { 31 namespace audio { 32 namespace effect { 33 namespace V2_0 { 34 namespace implementation { 35 36 using ::android::hardware::audio::common::V2_0::AudioDevice; 37 using ::android::hardware::audio::common::V2_0::AudioMode; 38 using ::android::hardware::audio::common::V2_0::AudioSource; 39 using ::android::hardware::audio::effect::V2_0::AudioBuffer; 40 using ::android::hardware::audio::effect::V2_0::EffectAuxChannelsConfig; 41 using ::android::hardware::audio::effect::V2_0::EffectConfig; 42 using ::android::hardware::audio::effect::V2_0::EffectDescriptor; 43 using ::android::hardware::audio::effect::V2_0::EffectOffloadParameter; 44 using ::android::hardware::audio::effect::V2_0::IEffect; 45 using ::android::hardware::audio::effect::V2_0::IEffectBufferProviderCallback; 46 using ::android::hardware::audio::effect::V2_0::INoiseSuppressionEffect; 47 using ::android::hardware::audio::effect::V2_0::Result; 48 using ::android::hardware::Return; 49 using ::android::hardware::Void; 50 using ::android::hardware::hidl_vec; 51 using ::android::hardware::hidl_string; 52 using ::android::sp; 53 54 struct NoiseSuppressionEffect : public INoiseSuppressionEffect { 55 explicit NoiseSuppressionEffect(effect_handle_t handle); 56 57 // Methods from ::android::hardware::audio::effect::V2_0::IEffect follow. 58 Return<Result> init() override; 59 Return<Result> setConfig( 60 const EffectConfig& config, 61 const sp<IEffectBufferProviderCallback>& inputBufferProvider, 62 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override; 63 Return<Result> reset() override; 64 Return<Result> enable() override; 65 Return<Result> disable() override; 66 Return<Result> setDevice(AudioDevice device) override; 67 Return<void> setAndGetVolume( 68 const hidl_vec<uint32_t>& volumes, setAndGetVolume_cb _hidl_cb) override; 69 Return<Result> volumeChangeNotification(const hidl_vec<uint32_t>& volumes) override; 70 Return<Result> setAudioMode(AudioMode mode) override; 71 Return<Result> setConfigReverse( 72 const EffectConfig& config, 73 const sp<IEffectBufferProviderCallback>& inputBufferProvider, 74 const sp<IEffectBufferProviderCallback>& outputBufferProvider) override; 75 Return<Result> setInputDevice(AudioDevice device) override; 76 Return<void> getConfig(getConfig_cb _hidl_cb) override; 77 Return<void> getConfigReverse(getConfigReverse_cb _hidl_cb) override; 78 Return<void> getSupportedAuxChannelsConfigs( 79 uint32_t maxConfigs, getSupportedAuxChannelsConfigs_cb _hidl_cb) override; 80 Return<void> getAuxChannelsConfig(getAuxChannelsConfig_cb _hidl_cb) override; 81 Return<Result> setAuxChannelsConfig(const EffectAuxChannelsConfig& config) override; 82 Return<Result> setAudioSource(AudioSource source) override; 83 Return<Result> offload(const EffectOffloadParameter& param) override; 84 Return<void> getDescriptor(getDescriptor_cb _hidl_cb) override; 85 Return<void> prepareForProcessing(prepareForProcessing_cb _hidl_cb) override; 86 Return<Result> setProcessBuffers( 87 const AudioBuffer& inBuffer, const AudioBuffer& outBuffer) override; 88 Return<void> command( 89 uint32_t commandId, 90 const hidl_vec<uint8_t>& data, 91 uint32_t resultMaxSize, 92 command_cb _hidl_cb) override; 93 Return<Result> setParameter( 94 const hidl_vec<uint8_t>& parameter, const hidl_vec<uint8_t>& value) override; 95 Return<void> getParameter( 96 const hidl_vec<uint8_t>& parameter, 97 uint32_t valueMaxSize, 98 getParameter_cb _hidl_cb) override; 99 Return<void> getSupportedConfigsForFeature( 100 uint32_t featureId, 101 uint32_t maxConfigs, 102 uint32_t configSize, 103 getSupportedConfigsForFeature_cb _hidl_cb) override; 104 Return<void> getCurrentConfigForFeature( 105 uint32_t featureId, 106 uint32_t configSize, 107 getCurrentConfigForFeature_cb _hidl_cb) override; 108 Return<Result> setCurrentConfigForFeature( 109 uint32_t featureId, const hidl_vec<uint8_t>& configData) override; 110 Return<Result> close() override; 111 112 // Methods from ::android::hardware::audio::effect::V2_0::INoiseSuppressionEffect follow. 113 Return<Result> setSuppressionLevel(INoiseSuppressionEffect::Level level) override; 114 Return<void> getSuppressionLevel(getSuppressionLevel_cb _hidl_cb) override; 115 Return<Result> setSuppressionType(INoiseSuppressionEffect::Type type) override; 116 Return<void> getSuppressionType(getSuppressionType_cb _hidl_cb) override; 117 Return<Result> setAllProperties( 118 const INoiseSuppressionEffect::AllProperties& properties) override; 119 Return<void> getAllProperties(getAllProperties_cb _hidl_cb) override; 120 121 private: 122 sp<Effect> mEffect; 123 124 virtual ~NoiseSuppressionEffect(); 125 126 void propertiesFromHal( 127 const t_ns_settings& halProperties, 128 INoiseSuppressionEffect::AllProperties* properties); 129 void propertiesToHal( 130 const INoiseSuppressionEffect::AllProperties& properties, 131 t_ns_settings* halProperties); 132 }; 133 134 } // namespace implementation 135 } // namespace V2_0 136 } // namespace effect 137 } // namespace audio 138 } // namespace hardware 139 } // namespace android 140 141 #endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H 142