Update VTSHalAudioEffectTargetTest with frameSize
- create buffer and check the fmq data with frameSize
- check effect state after open/close/command
Bug: 338040049
Test: atest --test-mapping hardware/interfaces/audio/aidl/vts
Change-Id: I45af2faec3cdcef5307fbdcf600a63d7da759261
diff --git a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
index 2f47d07..d23bdc9 100644
--- a/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalAudioEffectTargetTest.cpp
@@ -200,7 +200,6 @@
// An effect instance is in INIT state by default after it was created.
TEST_P(AudioEffectTest, InitStateAfterCreation) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -208,7 +207,6 @@
TEST_P(AudioEffectTest, IdleStateAfterOpen) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -216,11 +214,8 @@
// An effect instance is in PROCESSING state after it receive an START command.
TEST_P(AudioEffectTest, ProcessingStateAfterStart) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -231,9 +226,7 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -243,9 +236,7 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -257,7 +248,6 @@
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -274,9 +264,7 @@
TEST_P(AudioEffectTest, StopCommandInIdleStateNoOp) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -285,9 +273,7 @@
TEST_P(AudioEffectTest, ResetCommandInIdleStateNoOp) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -296,16 +282,11 @@
TEST_P(AudioEffectTest, RepeatStartAndStop) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -314,16 +295,10 @@
TEST_P(AudioEffectTest, RepeatStartAndReset) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -332,14 +307,11 @@
TEST_P(AudioEffectTest, CloseProcessingStateEffects) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(close(mEffect, EX_ILLEGAL_STATE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -348,8 +320,6 @@
TEST_P(AudioEffectTest, DestroyOpenEffects) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE));
// cleanup
@@ -361,32 +331,22 @@
TEST_P(AudioEffectTest, DestroyProcessingEffects) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE));
// cleanup
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
TEST_P(AudioEffectTest, NormalSequenceStates) {
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -430,7 +390,6 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
Parameter::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -447,9 +406,7 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
Parameter::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -465,7 +422,6 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
Parameter::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -473,7 +429,6 @@
ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -484,7 +439,6 @@
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
Parameter::Common common = createParamCommon(0 /* session */, 1 /* ioHandle */,
44100 /* iSampleRate */, 44100 /* oSampleRate */);
@@ -492,12 +446,10 @@
ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -511,9 +463,7 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
-
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
std::vector<AudioDeviceDescription> deviceDescs = {
{.type = AudioDeviceType::IN_DEFAULT,
@@ -525,7 +475,6 @@
setAndGetParameter(id, Parameter::make<Parameter::deviceDescription>(deviceDescs)));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -541,7 +490,6 @@
ASSERT_NO_FATAL_FAILURE(open(mEffect));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::mode);
ASSERT_NO_FATAL_FAILURE(
@@ -550,7 +498,6 @@
setAndGetParameter(id, Parameter::make<Parameter::mode>(AudioMode::IN_COMMUNICATION)));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -564,9 +511,7 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
-
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::source);
ASSERT_NO_FATAL_FAILURE(
@@ -575,7 +520,6 @@
id, Parameter::make<Parameter::source>(AudioSource::VOICE_RECOGNITION)));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -589,9 +533,7 @@
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
ASSERT_NO_FATAL_FAILURE(open(mEffect));
-
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::volumeStereo);
Parameter::VolumeStereo volume = {.left = 10.0, .right = 10.0};
@@ -605,7 +547,6 @@
}
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -638,7 +579,7 @@
ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
ASSERT_TRUE(statusMQ->isValid());
expectDataMqUpdateEventFlag(statusMQ);
- EXPECT_IS_OK(mEffect->reopen(&ret));
+ ASSERT_NO_FATAL_FAILURE(reopen(mEffect, common, &ret));
inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
ASSERT_TRUE(statusMQ->isValid());
@@ -649,7 +590,7 @@
ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
ASSERT_TRUE(statusMQ->isValid());
expectDataMqUpdateEventFlag(statusMQ);
- EXPECT_IS_OK(mEffect->reopen(&ret));
+ ASSERT_NO_FATAL_FAILURE(reopen(mEffect, common, &ret));
inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
ASSERT_TRUE(statusMQ->isValid());
@@ -671,26 +612,9 @@
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
- auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
- ASSERT_TRUE(statusMQ->isValid());
- auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
- ASSERT_TRUE(inputMQ->isValid());
- auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
- ASSERT_TRUE(outputMQ->isValid());
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
- std::vector<float> buffer;
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
-
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -705,31 +629,12 @@
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
- auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
- ASSERT_TRUE(statusMQ->isValid());
- auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
- ASSERT_TRUE(inputMQ->isValid());
- auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
- ASSERT_TRUE(outputMQ->isValid());
- std::vector<float> buffer;
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 0, outputMQ, buffer.size(), buffer));
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -751,18 +656,10 @@
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
ASSERT_TRUE(statusMQ->isValid());
- auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
- ASSERT_TRUE(inputMQ->isValid());
- auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
- ASSERT_TRUE(outputMQ->isValid());
- std::vector<float> buffer;
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
// set a new common parameter with different IO frameCount, reopen
Parameter::Id id = Parameter::Id::make<Parameter::Id::commonTag>(Parameter::common);
@@ -771,22 +668,12 @@
ASSERT_NO_FATAL_FAILURE(setAndGetParameter(id, Parameter::make<Parameter::common>(common)));
ASSERT_TRUE(statusMQ->isValid());
expectDataMqUpdateEventFlag(statusMQ);
- EXPECT_IS_OK(mEffect->reopen(&ret));
- inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
- outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
- ASSERT_TRUE(statusMQ->isValid());
- ASSERT_TRUE(inputMQ->isValid());
- ASSERT_TRUE(outputMQ->isValid());
+ ASSERT_NO_FATAL_FAILURE(reopen(mEffect, common, &ret));
- // verify data consume again
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+ inputBuffer.resize(mInputSamples);
+ outputBuffer.resize(mOutputSamples);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -809,19 +696,15 @@
auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
ASSERT_TRUE(outputMQ->isValid());
- std::vector<float> buffer;
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, mVersion));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
+ EffectHelper::readFromFmq(statusMQ, 1, outputMQ, outputBuffer.size(), outputBuffer));
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
-
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -836,31 +719,10 @@
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
- auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
- ASSERT_TRUE(statusMQ->isValid());
- auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
- ASSERT_TRUE(inputMQ->isValid());
- auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
- ASSERT_TRUE(outputMQ->isValid());
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
- std::vector<float> buffer;
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
-
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion, 2));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -876,33 +738,12 @@
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
- auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
- ASSERT_TRUE(statusMQ->isValid());
- auto inputMQ = std::make_unique<EffectHelper::DataMQ>(ret.inputDataMQ);
- ASSERT_TRUE(inputMQ->isValid());
- auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
- ASSERT_TRUE(outputMQ->isValid());
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- std::vector<float> buffer;
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer));
-
- ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion, 2));
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer, outputBuffer, mEffect, &ret, mVersion, 2));
ASSERT_NO_FATAL_FAILURE(close(mEffect));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
@@ -918,6 +759,7 @@
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
IEffect::OpenEffectReturn ret;
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
+ std::vector<float> inputBuffer(mInputSamples), outputBuffer(mOutputSamples);
ASSERT_NO_FATAL_FAILURE(close(mEffect));
auto statusMQ = std::make_unique<EffectHelper::StatusMQ>(ret.statusMQ);
@@ -927,10 +769,8 @@
auto outputMQ = std::make_unique<EffectHelper::DataMQ>(ret.outputDataMQ);
ASSERT_TRUE(outputMQ->isValid());
- std::vector<float> buffer;
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common, inputMQ, buffer));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, buffer, mVersion));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ, inputMQ, inputBuffer, mVersion));
+ EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, outputBuffer));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
}
@@ -951,42 +791,19 @@
IEffect::OpenEffectReturn ret1, ret2;
ASSERT_NO_FATAL_FAILURE(open(effect1, common1, std::nullopt /* specific */, &ret1, EX_NONE));
ASSERT_NO_FATAL_FAILURE(open(effect2, common2, std::nullopt /* specific */, &ret2, EX_NONE));
- ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::PROCESSING));
- ASSERT_NO_FATAL_FAILURE(command(effect2, CommandId::START));
- ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::PROCESSING));
+ std::vector<float> inputBuffer1(kInputFrameCount * mInputFrameSize / sizeof(float)),
+ outputBuffer1(kOutputFrameCount * mOutputFrameSize / sizeof(float));
+ std::vector<float> inputBuffer2(2 * kInputFrameCount * mInputFrameSize / sizeof(float)),
+ outputBuffer2(2 * kOutputFrameCount * mOutputFrameSize / sizeof(float));
- auto statusMQ1 = std::make_unique<EffectHelper::StatusMQ>(ret1.statusMQ);
- ASSERT_TRUE(statusMQ1->isValid());
- auto inputMQ1 = std::make_unique<EffectHelper::DataMQ>(ret1.inputDataMQ);
- ASSERT_TRUE(inputMQ1->isValid());
- auto outputMQ1 = std::make_unique<EffectHelper::DataMQ>(ret1.outputDataMQ);
- ASSERT_TRUE(outputMQ1->isValid());
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer1, outputBuffer1, effect1, &ret1, mVersion, 2));
+ ASSERT_NO_FATAL_FAILURE(
+ processAndWriteToOutput(inputBuffer2, outputBuffer2, effect2, &ret2, mVersion, 2));
- std::vector<float> buffer1, buffer2;
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common1, inputMQ1, buffer1));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ1, inputMQ1, buffer1, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ1, 1, outputMQ1, buffer1.size(), buffer1));
-
- auto statusMQ2 = std::make_unique<EffectHelper::StatusMQ>(ret2.statusMQ);
- ASSERT_TRUE(statusMQ2->isValid());
- auto inputMQ2 = std::make_unique<EffectHelper::DataMQ>(ret2.inputDataMQ);
- ASSERT_TRUE(inputMQ2->isValid());
- auto outputMQ2 = std::make_unique<EffectHelper::DataMQ>(ret2.outputDataMQ);
- ASSERT_TRUE(outputMQ2->isValid());
- EXPECT_NO_FATAL_FAILURE(EffectHelper::allocateInputData(common2, inputMQ2, buffer2));
- EXPECT_NO_FATAL_FAILURE(EffectHelper::writeToFmq(statusMQ2, inputMQ2, buffer2, mVersion));
- EXPECT_NO_FATAL_FAILURE(
- EffectHelper::readFromFmq(statusMQ2, 1, outputMQ2, buffer2.size(), buffer2));
-
- ASSERT_NO_FATAL_FAILURE(command(effect1, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(effect1, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(effect1));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect1));
- ASSERT_NO_FATAL_FAILURE(command(effect2, CommandId::STOP));
- ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::IDLE));
ASSERT_NO_FATAL_FAILURE(close(effect2));
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect2));
}