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