AIDL libAudioHal: Add effect AIDL conversion for NoiseSuppression
Bug: 258124419
Test: Enable AIDL in libaudiohal
Test: atest EffectsFactoryHalInterfaceTest
Change-Id: I19acbc88528d746731588504bd6cb5303d3ed031
diff --git a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.cpp b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.cpp
index 5faf645..69184cf 100644
--- a/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.cpp
+++ b/media/libaudiohal/impl/effectsAidlConversion/AidlConversionNoiseSuppression.cpp
@@ -34,33 +34,77 @@
namespace effect {
using ::aidl::android::aidl_utils::statusTFromBinderStatus;
+using ::aidl::android::getParameterSpecificField;
using ::aidl::android::hardware::audio::effect::Parameter;
+using ::aidl::android::hardware::audio::effect::NoiseSuppression;
using ::android::status_t;
using utils::EffectParamReader;
using utils::EffectParamWriter;
status_t AidlConversionNoiseSuppression::setParameter(EffectParamReader& param) {
- uint32_t type = 0;
- uint16_t value = 0;
+ uint32_t type = 0, value = 0;
if (!param.validateParamValueSize(sizeof(uint32_t), sizeof(uint16_t)) ||
OK != param.readFromParameter(&type) || OK != param.readFromValue(&value)) {
ALOGE("%s invalid param %s", __func__, param.toString().c_str());
return BAD_VALUE;
}
Parameter aidlParam;
- // TODO
+ switch (type) {
+ case NS_PARAM_LEVEL: {
+ aidlParam = MAKE_SPECIFIC_PARAMETER(NoiseSuppression, noiseSuppression, level,
+ static_cast<NoiseSuppression::Level>(value));
+ break;
+ }
+ case NS_PARAM_TYPE: {
+ aidlParam = MAKE_SPECIFIC_PARAMETER(NoiseSuppression, noiseSuppression, type,
+ static_cast<NoiseSuppression::Type>(value));
+ break;
+ }
+ default: {
+ // TODO: implement vendor extension parameters
+ ALOGW("%s unknown param %s", __func__, param.toString().c_str());
+ return BAD_VALUE;
+ }
+ }
return statusTFromBinderStatus(mEffect->setParameter(aidlParam));
}
status_t AidlConversionNoiseSuppression::getParameter(EffectParamWriter& param) {
- uint32_t type = 0, value = 0;
+ uint32_t paramType = 0, value = 0;
if (!param.validateParamValueSize(sizeof(uint32_t), sizeof(uint32_t)) ||
- OK != param.readFromParameter(&type)) {
+ OK != param.readFromParameter(¶mType)) {
ALOGE("%s invalid param %s", __func__, param.toString().c_str());
param.setStatus(BAD_VALUE);
return BAD_VALUE;
}
- // TODO
+ Parameter aidlParam;
+ switch (paramType) {
+ case NS_PARAM_LEVEL: {
+ Parameter::Id id = MAKE_SPECIFIC_PARAMETER_ID(NoiseSuppression, noiseSuppressionTag,
+ NoiseSuppression::level);
+ RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mEffect->getParameter(id, &aidlParam)));
+ NoiseSuppression::Level level = VALUE_OR_RETURN_STATUS(
+ GET_PARAMETER_SPECIFIC_FIELD(aidlParam, NoiseSuppression, noiseSuppression,
+ NoiseSuppression::level, NoiseSuppression::Level));
+ value = static_cast<uint32_t>(level);
+ break;
+ }
+ case NS_PARAM_TYPE: {
+ Parameter::Id id = MAKE_SPECIFIC_PARAMETER_ID(NoiseSuppression, noiseSuppressionTag,
+ NoiseSuppression::type);
+ RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mEffect->getParameter(id, &aidlParam)));
+ NoiseSuppression::Type nsType = VALUE_OR_RETURN_STATUS(
+ GET_PARAMETER_SPECIFIC_FIELD(aidlParam, NoiseSuppression, noiseSuppression,
+ NoiseSuppression::type, NoiseSuppression::Type));
+ value = static_cast<uint32_t>(nsType);
+ break;
+ }
+ default: {
+ // TODO: implement vendor extension parameters
+ ALOGW("%s unknown param %s", __func__, param.toString().c_str());
+ return BAD_VALUE;
+ }
+ }
return param.writeToValue(&value);
}
diff --git a/media/libaudiohal/tests/EffectsFactoryHalInterface_test.cpp b/media/libaudiohal/tests/EffectsFactoryHalInterface_test.cpp
index dda608b..ce122e5 100644
--- a/media/libaudiohal/tests/EffectsFactoryHalInterface_test.cpp
+++ b/media/libaudiohal/tests/EffectsFactoryHalInterface_test.cpp
@@ -33,6 +33,7 @@
#include <system/audio_effects/effect_dynamicsprocessing.h>
#include <system/audio_effects/effect_hapticgenerator.h>
#include <system/audio_effects/effect_loudnessenhancer.h>
+#include <system/audio_effects/effect_ns.h>
#include <system/audio_effect.h>
#include <gtest/gtest.h>
@@ -176,7 +177,10 @@
std::make_tuple(
FX_IID_LOUDNESS_ENHANCER,
createEffectParamCombination(LOUDNESS_ENHANCER_PARAM_TARGET_GAIN_MB, 5 /* gain */,
- sizeof(int32_t) /* returnValueSize */))};
+ sizeof(int32_t) /* returnValueSize */)),
+ std::make_tuple(FX_IID_NS,
+ createEffectParamCombination(NS_PARAM_LEVEL, 1 /* level */,
+ sizeof(int32_t) /* returnValueSize */))};
class libAudioHalEffectParamTest : public ::testing::TestWithParam<EffectParamTestTuple> {
public: