Merge "Update VTSHalAudioEffectTargetTest with frameSize" into main

This commit is contained in:
Shunkai Yao
2024-06-20 23:35:28 +00:00
committed by Gerrit Code Review
3 changed files with 128 additions and 259 deletions

View File

@@ -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>

View File

@@ -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;
@@ -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) {
@@ -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);
@@ -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();
@@ -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,
@@ -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,
@@ -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)) {
@@ -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,
@@ -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));
}
// Read the updated message queues into buffer
EXPECT_NO_FATAL_FAILURE(EffectHelper::readFromFmq(statusMQ, 1, outputMQ,
outputBuffer.size(), outputBuffer));
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
@@ -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;
};

View File

@@ -200,7 +200,6 @@ TEST_P(AudioEffectTest, DescriptorExistAndUnique) {
// 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, InitStateAfterCreation) {
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 @@ TEST_P(AudioEffectTest, IdleStateAfterOpen) {
// 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 @@ TEST_P(AudioEffectTest, IdleStateAfterStop) {
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 @@ TEST_P(AudioEffectTest, IdleStateAfterReset) {
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 @@ TEST_P(AudioEffectTest, InitStateAfterClose) {
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, NoCommandAcceptedBeforeOpen) {
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, StopCommandInIdleStateNoOp) {
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, ResetCommandInIdleStateNoOp) {
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, RepeatStartAndStop) {
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, RepeatStartAndReset) {
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, CloseProcessingStateEffects) {
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, DestroyOpenEffects) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterInProcessing) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterInIdle) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAfterStop) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAfterStop) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAfterReset) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAfterReset) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterDeviceDescription) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAudioMode) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterAudioSource) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterVolume) {
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 @@ TEST_P(AudioEffectTest, SetAndGetParameterVolume) {
}
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 @@ TEST_P(AudioEffectDataPathTest, SetCommonParameterAndReopen) {
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 @@ TEST_P(AudioEffectDataPathTest, SetCommonParameterAndReopen) {
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 @@ TEST_P(AudioEffectDataPathTest, ConsumeDataInProcessingState) {
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 @@ TEST_P(AudioEffectDataPathTest, ConsumeDataAfterRestart) {
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 @@ TEST_P(AudioEffectDataPathTest, ConsumeDataAfterReopen) {
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 @@ TEST_P(AudioEffectDataPathTest, ConsumeDataAfterReopen) {
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 @@ TEST_P(AudioEffectDataPathTest, SendDataAtIdleAndConsumeDataInProcessing) {
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 @@ TEST_P(AudioEffectDataPathTest, ProcessDataMultipleTimes) {
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 @@ TEST_P(AudioEffectDataPathTest, ConsumeDataAndRestart) {
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 @@ TEST_P(AudioEffectDataPathTest, NotConsumeDataByClosedEffect) {
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 @@ TEST_P(AudioEffectDataPathTest, NotConsumeDataByClosedEffect) {
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 @@ TEST_P(AudioEffectDataPathTest, ConsumeDataMultipleEffects) {
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));
}