Loading audio/aidl/default/audio_effects_config.xml +0 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,6 @@ <effect name="extension_effect" library="extensioneffect" uuid="fa81dd00-588b-11ed-9b6a-0242ac120002" type="fa81de0e-588b-11ed-9b6a-0242ac120002"/> <effect name="acoustic_echo_canceler" library="pre_processing" uuid="bb392ec0-8d4d-11e0-a896-0002a5d5c51b"/> <effect name="noise_suppression" library="pre_processing" uuid="c06c8400-8e06-11e0-9cb6-0002a5d5c51b"/> <effect name="spatializer" library="spatializersw" uuid="fa81a880-588b-11ed-9b6a-0242ac120002"/> </effects> <preprocess> Loading audio/aidl/vts/EffectHelper.h +86 −33 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ class EffectHelper { ASSERT_STATUS(status, factory->createEffect(id.uuid, &effect)); if (status == EX_NONE) { ASSERT_NE(effect, nullptr) << toString(id.uuid); ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT)); } mIsSpatializer = id.type == getEffectTypeUuidSpatializer(); mDescriptor = desc; Loading @@ -111,11 +112,17 @@ class EffectHelper { ASSERT_STATUS(status, factory->destroyEffect(effect)); } static void open(std::shared_ptr<IEffect> effect, const Parameter::Common& common, const std::optional<Parameter::Specific>& specific, IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) { void open(std::shared_ptr<IEffect> effect, const Parameter::Common& common, const std::optional<Parameter::Specific>& specific, IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->open(common, specific, ret)); if (status != EX_NONE) { return; } ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE)); updateFrameSize(common); } void open(std::shared_ptr<IEffect> effect, int session = 0, binder_status_t status = EX_NONE) { Loading @@ -125,21 +132,37 @@ class EffectHelper { ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, status)); } void reopen(std::shared_ptr<IEffect> effect, const Parameter::Common& common, IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->reopen(ret)); if (status != EX_NONE) { return; } updateFrameSize(common); } static void closeIgnoreRet(std::shared_ptr<IEffect> effect) { if (effect) { effect->close(); } } static void close(std::shared_ptr<IEffect> effect, binder_status_t status = EX_NONE) { if (effect) { ASSERT_STATUS(status, effect->close()); if (status == EX_NONE) { ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT)); } } } static void getDescriptor(std::shared_ptr<IEffect> effect, Descriptor& desc, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->getDescriptor(&desc)); } static void expectState(std::shared_ptr<IEffect> effect, State expectState, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); Loading @@ -147,27 +170,35 @@ class EffectHelper { ASSERT_STATUS(status, effect->getState(&state)); ASSERT_EQ(expectState, state); } static void commandIgnoreRet(std::shared_ptr<IEffect> effect, CommandId command) { if (effect) { effect->command(command); } } static void command(std::shared_ptr<IEffect> effect, CommandId command, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->command(command)); if (status != EX_NONE) { return; } switch (command) { case CommandId::START: ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING)); break; case CommandId::STOP: FALLTHROUGH_INTENDED; case CommandId::RESET: ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE)); break; default: return; } static void allocateInputData(const Parameter::Common common, std::unique_ptr<DataMQ>& mq, std::vector<float>& buffer) { ASSERT_NE(mq, nullptr); auto frameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes( common.input.base.format, common.input.base.channelMask); const size_t floatsToWrite = mq->availableToWrite(); ASSERT_NE(0UL, floatsToWrite); ASSERT_EQ(frameSize * common.input.frameCount, floatsToWrite * sizeof(float)); buffer.resize(floatsToWrite); std::fill(buffer.begin(), buffer.end(), 0x5a); } static void writeToFmq(std::unique_ptr<StatusMQ>& statusMq, std::unique_ptr<DataMQ>& dataMq, const std::vector<float>& buffer, int version) { const size_t available = dataMq->availableToWrite(); Loading @@ -184,6 +215,7 @@ class EffectHelper { : kEventFlagNotEmpty); ASSERT_EQ(::android::OK, EventFlag::deleteEventFlag(&efGroup)); } static void readFromFmq(std::unique_ptr<StatusMQ>& statusMq, size_t statusNum, std::unique_ptr<DataMQ>& dataMq, size_t expectFloats, std::vector<float>& buffer, Loading @@ -204,6 +236,7 @@ class EffectHelper { ASSERT_TRUE(dataMq->read(buffer.data(), expectFloats)); } } static void expectDataMqUpdateEventFlag(std::unique_ptr<StatusMQ>& statusMq) { EventFlag* efGroup; ASSERT_EQ(::android::OK, Loading @@ -218,8 +251,10 @@ class EffectHelper { Parameter::Common createParamCommon(int session = 0, int ioHandle = -1, int iSampleRate = 48000, int oSampleRate = 48000, long iFrameCount = 0x100, long oFrameCount = 0x100) { AudioChannelLayout defaultLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>( AudioChannelLayout inputLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>( AudioChannelLayout::LAYOUT_STEREO); AudioChannelLayout outputLayout = inputLayout; // query supported input layout and use it as the default parameter in common if (mIsSpatializer && isRangeValid<Range::spatializer>(Spatializer::supportedChannelLayout, mDescriptor.capability)) { Loading @@ -229,12 +264,14 @@ class EffectHelper { layoutRange && 0 != (layouts = layoutRange->min.get<Spatializer::supportedChannelLayout>()) .size()) { defaultLayout = layouts[0]; inputLayout = layouts[0]; } } return createParamCommon(session, ioHandle, iSampleRate, oSampleRate, iFrameCount, oFrameCount, defaultLayout, defaultLayout); oFrameCount, inputLayout, outputLayout); } static Parameter::Common createParamCommon(int session, int ioHandle, int iSampleRate, int oSampleRate, long iFrameCount, long oFrameCount, AudioChannelLayout inputChannelLayout, Loading Loading @@ -333,33 +370,38 @@ class EffectHelper { static void processAndWriteToOutput(std::vector<float>& inputBuffer, std::vector<float>& outputBuffer, const std::shared_ptr<IEffect>& mEffect, IEffect::OpenEffectReturn* mOpenEffectReturn) { const std::shared_ptr<IEffect>& effect, IEffect::OpenEffectReturn* openEffectReturn, int version = -1, int times = 1) { // Initialize AidlMessagequeues auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(mOpenEffectReturn->statusMQ); auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(openEffectReturn->statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->inputDataMQ); auto inputMQ = std::make_unique<EffectHelper::DataMQ>(openEffectReturn->inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->outputDataMQ); auto outputMQ = std::make_unique<EffectHelper::DataMQ>(openEffectReturn->outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); // Enabling the process ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START)); // Write from buffer to message queues and calling process EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, [&]() { int version = 0; return (mEffect && mEffect->getInterfaceVersion(&version).isOk()) ? version : 0; }())); if (version == -1) { ASSERT_IS_OK(effect->getInterfaceVersion(&version)); } for (int i = 0; i < times; i++) { EXPECT_NO_FATAL_FAILURE( EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, version)); // Read the updated message queues into buffer EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 1, outputMQ, outputBuffer.size(), outputBuffer)); } ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, outputBuffer)); // Disable the process ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET)); } // Find FFT bin indices for testFrequencies and get bin center frequencies Loading Loading @@ -403,6 +445,17 @@ class EffectHelper { return bufferMag; } void updateFrameSize(const Parameter::Common& common) { mInputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes( common.input.base.format, common.input.base.channelMask); mInputSamples = common.input.frameCount * mInputFrameSize / sizeof(float); mOutputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes( common.output.base.format, common.output.base.channelMask); mOutputSamples = common.output.frameCount * mOutputFrameSize / sizeof(float); } bool mIsSpatializer; Descriptor mDescriptor; size_t mInputFrameSize, mOutputFrameSize; size_t mInputSamples, mOutputSamples; }; audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp +43 −226 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
audio/aidl/default/audio_effects_config.xml +0 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,6 @@ <effect name="extension_effect" library="extensioneffect" uuid="fa81dd00-588b-11ed-9b6a-0242ac120002" type="fa81de0e-588b-11ed-9b6a-0242ac120002"/> <effect name="acoustic_echo_canceler" library="pre_processing" uuid="bb392ec0-8d4d-11e0-a896-0002a5d5c51b"/> <effect name="noise_suppression" library="pre_processing" uuid="c06c8400-8e06-11e0-9cb6-0002a5d5c51b"/> <effect name="spatializer" library="spatializersw" uuid="fa81a880-588b-11ed-9b6a-0242ac120002"/> </effects> <preprocess> Loading
audio/aidl/vts/EffectHelper.h +86 −33 Original line number Diff line number Diff line Loading @@ -92,6 +92,7 @@ class EffectHelper { ASSERT_STATUS(status, factory->createEffect(id.uuid, &effect)); if (status == EX_NONE) { ASSERT_NE(effect, nullptr) << toString(id.uuid); ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT)); } mIsSpatializer = id.type == getEffectTypeUuidSpatializer(); mDescriptor = desc; Loading @@ -111,11 +112,17 @@ class EffectHelper { ASSERT_STATUS(status, factory->destroyEffect(effect)); } static void open(std::shared_ptr<IEffect> effect, const Parameter::Common& common, const std::optional<Parameter::Specific>& specific, IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) { void open(std::shared_ptr<IEffect> effect, const Parameter::Common& common, const std::optional<Parameter::Specific>& specific, IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->open(common, specific, ret)); if (status != EX_NONE) { return; } ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE)); updateFrameSize(common); } void open(std::shared_ptr<IEffect> effect, int session = 0, binder_status_t status = EX_NONE) { Loading @@ -125,21 +132,37 @@ class EffectHelper { ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, status)); } void reopen(std::shared_ptr<IEffect> effect, const Parameter::Common& common, IEffect::OpenEffectReturn* ret, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->reopen(ret)); if (status != EX_NONE) { return; } updateFrameSize(common); } static void closeIgnoreRet(std::shared_ptr<IEffect> effect) { if (effect) { effect->close(); } } static void close(std::shared_ptr<IEffect> effect, binder_status_t status = EX_NONE) { if (effect) { ASSERT_STATUS(status, effect->close()); if (status == EX_NONE) { ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT)); } } } static void getDescriptor(std::shared_ptr<IEffect> effect, Descriptor& desc, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->getDescriptor(&desc)); } static void expectState(std::shared_ptr<IEffect> effect, State expectState, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); Loading @@ -147,27 +170,35 @@ class EffectHelper { ASSERT_STATUS(status, effect->getState(&state)); ASSERT_EQ(expectState, state); } static void commandIgnoreRet(std::shared_ptr<IEffect> effect, CommandId command) { if (effect) { effect->command(command); } } static void command(std::shared_ptr<IEffect> effect, CommandId command, binder_status_t status = EX_NONE) { ASSERT_NE(effect, nullptr); ASSERT_STATUS(status, effect->command(command)); if (status != EX_NONE) { return; } switch (command) { case CommandId::START: ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING)); break; case CommandId::STOP: FALLTHROUGH_INTENDED; case CommandId::RESET: ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE)); break; default: return; } static void allocateInputData(const Parameter::Common common, std::unique_ptr<DataMQ>& mq, std::vector<float>& buffer) { ASSERT_NE(mq, nullptr); auto frameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes( common.input.base.format, common.input.base.channelMask); const size_t floatsToWrite = mq->availableToWrite(); ASSERT_NE(0UL, floatsToWrite); ASSERT_EQ(frameSize * common.input.frameCount, floatsToWrite * sizeof(float)); buffer.resize(floatsToWrite); std::fill(buffer.begin(), buffer.end(), 0x5a); } static void writeToFmq(std::unique_ptr<StatusMQ>& statusMq, std::unique_ptr<DataMQ>& dataMq, const std::vector<float>& buffer, int version) { const size_t available = dataMq->availableToWrite(); Loading @@ -184,6 +215,7 @@ class EffectHelper { : kEventFlagNotEmpty); ASSERT_EQ(::android::OK, EventFlag::deleteEventFlag(&efGroup)); } static void readFromFmq(std::unique_ptr<StatusMQ>& statusMq, size_t statusNum, std::unique_ptr<DataMQ>& dataMq, size_t expectFloats, std::vector<float>& buffer, Loading @@ -204,6 +236,7 @@ class EffectHelper { ASSERT_TRUE(dataMq->read(buffer.data(), expectFloats)); } } static void expectDataMqUpdateEventFlag(std::unique_ptr<StatusMQ>& statusMq) { EventFlag* efGroup; ASSERT_EQ(::android::OK, Loading @@ -218,8 +251,10 @@ class EffectHelper { Parameter::Common createParamCommon(int session = 0, int ioHandle = -1, int iSampleRate = 48000, int oSampleRate = 48000, long iFrameCount = 0x100, long oFrameCount = 0x100) { AudioChannelLayout defaultLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>( AudioChannelLayout inputLayout = AudioChannelLayout::make<AudioChannelLayout::layoutMask>( AudioChannelLayout::LAYOUT_STEREO); AudioChannelLayout outputLayout = inputLayout; // query supported input layout and use it as the default parameter in common if (mIsSpatializer && isRangeValid<Range::spatializer>(Spatializer::supportedChannelLayout, mDescriptor.capability)) { Loading @@ -229,12 +264,14 @@ class EffectHelper { layoutRange && 0 != (layouts = layoutRange->min.get<Spatializer::supportedChannelLayout>()) .size()) { defaultLayout = layouts[0]; inputLayout = layouts[0]; } } return createParamCommon(session, ioHandle, iSampleRate, oSampleRate, iFrameCount, oFrameCount, defaultLayout, defaultLayout); oFrameCount, inputLayout, outputLayout); } static Parameter::Common createParamCommon(int session, int ioHandle, int iSampleRate, int oSampleRate, long iFrameCount, long oFrameCount, AudioChannelLayout inputChannelLayout, Loading Loading @@ -333,33 +370,38 @@ class EffectHelper { static void processAndWriteToOutput(std::vector<float>& inputBuffer, std::vector<float>& outputBuffer, const std::shared_ptr<IEffect>& mEffect, IEffect::OpenEffectReturn* mOpenEffectReturn) { const std::shared_ptr<IEffect>& effect, IEffect::OpenEffectReturn* openEffectReturn, int version = -1, int times = 1) { // Initialize AidlMessagequeues auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(mOpenEffectReturn->statusMQ); auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(openEffectReturn->statusMQ); ASSERT_TRUE(statusMQ->isValid()); auto inputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->inputDataMQ); auto inputMQ = std::make_unique<EffectHelper::DataMQ>(openEffectReturn->inputDataMQ); ASSERT_TRUE(inputMQ->isValid()); auto outputMQ = std::make_unique<EffectHelper::DataMQ>(mOpenEffectReturn->outputDataMQ); auto outputMQ = std::make_unique<EffectHelper::DataMQ>(openEffectReturn->outputDataMQ); ASSERT_TRUE(outputMQ->isValid()); // Enabling the process ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING)); ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START)); // Write from buffer to message queues and calling process EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, [&]() { int version = 0; return (mEffect && mEffect->getInterfaceVersion(&version).isOk()) ? version : 0; }())); if (version == -1) { ASSERT_IS_OK(effect->getInterfaceVersion(&version)); } for (int i = 0; i < times; i++) { EXPECT_NO_FATAL_FAILURE( EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, version)); // Read the updated message queues into buffer EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 1, outputMQ, outputBuffer.size(), outputBuffer)); } ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP)); EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, outputBuffer)); // Disable the process ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET)); ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE)); ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET)); } // Find FFT bin indices for testFrequencies and get bin center frequencies Loading Loading @@ -403,6 +445,17 @@ class EffectHelper { return bufferMag; } void updateFrameSize(const Parameter::Common& common) { mInputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes( common.input.base.format, common.input.base.channelMask); mInputSamples = common.input.frameCount * mInputFrameSize / sizeof(float); mOutputFrameSize = ::aidl::android::hardware::audio::common::getFrameSizeInBytes( common.output.base.format, common.output.base.channelMask); mOutputSamples = common.output.frameCount * mOutputFrameSize / sizeof(float); } bool mIsSpatializer; Descriptor mDescriptor; size_t mInputFrameSize, mOutputFrameSize; size_t mInputSamples, mOutputSamples; };
audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp +43 −226 File changed.Preview size limit exceeded, changes collapsed. Show changes