|
|
|
@ -49,18 +49,30 @@ using aidl::android::hardware::audio::effect::Parameter;
|
|
|
|
|
using aidl::android::hardware::audio::effect::State;
|
|
|
|
|
|
|
|
|
|
enum ParamName { PARAM_INSTANCE_NAME };
|
|
|
|
|
using EffectTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor::Identity>>;
|
|
|
|
|
using EffectTestParam = std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>>;
|
|
|
|
|
|
|
|
|
|
class AudioEffectTest : public testing::TestWithParam<EffectTestParam>, public EffectHelper {
|
|
|
|
|
public:
|
|
|
|
|
AudioEffectTest() { std::tie(mFactory, mIdentity) = std::get<PARAM_INSTANCE_NAME>(GetParam()); }
|
|
|
|
|
AudioEffectTest() {
|
|
|
|
|
std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetUp() override {}
|
|
|
|
|
void TearDown() override {}
|
|
|
|
|
|
|
|
|
|
void TearDown() override {
|
|
|
|
|
// Do the cleanup for every test case
|
|
|
|
|
if (mEffect) {
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(commandIgnoreRet(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(closeIgnoreRet(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroyIgnoreRet(mFactory, mEffect));
|
|
|
|
|
mEffect.reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const long kInputFrameCount = 0x100, kOutputFrameCount = 0x100;
|
|
|
|
|
std::shared_ptr<IFactory> mFactory;
|
|
|
|
|
Descriptor::Identity mIdentity;
|
|
|
|
|
std::shared_ptr<IEffect> mEffect;
|
|
|
|
|
Descriptor mDescriptor;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, SetupAndTearDown) {
|
|
|
|
@ -68,30 +80,27 @@ TEST_P(AudioEffectTest, SetupAndTearDown) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, CreateAndDestroy) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, OpenAndClose) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, CloseUnopenedEffect) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, DoubleOpenAndClose) {
|
|
|
|
|
std::shared_ptr<IEffect> effect1, effect2;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect1));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect2, 1 /* session */));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect1));
|
|
|
|
@ -102,9 +111,9 @@ TEST_P(AudioEffectTest, DoubleOpenAndClose) {
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, TripleOpenAndClose) {
|
|
|
|
|
std::shared_ptr<IEffect> effect1, effect2, effect3;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect3, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect3, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect1));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect2, 1 /* session */));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect3, 2 /* session */));
|
|
|
|
@ -117,513 +126,505 @@ TEST_P(AudioEffectTest, TripleOpenAndClose) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, GetDescritorBeforeOpen) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
Descriptor desc;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(effect, desc));
|
|
|
|
|
EXPECT_EQ(mIdentity.toString(), desc.common.id.toString());
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, desc));
|
|
|
|
|
EXPECT_EQ(mDescriptor.common, desc.common);
|
|
|
|
|
// Effect implementation Must fill in implementor and name
|
|
|
|
|
EXPECT_NE("", desc.common.name);
|
|
|
|
|
EXPECT_NE("", desc.common.implementor);
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, GetDescritorAfterOpen) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
Descriptor beforeOpen, afterOpen, afterClose;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(effect, beforeOpen));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(effect, afterOpen));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, beforeOpen));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, afterOpen));
|
|
|
|
|
EXPECT_EQ(beforeOpen.toString(), afterOpen.toString()) << "\n"
|
|
|
|
|
<< beforeOpen.toString() << "\n"
|
|
|
|
|
<< afterOpen.toString();
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(effect, afterClose));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, afterClose));
|
|
|
|
|
EXPECT_EQ(beforeOpen.toString(), afterClose.toString()) << "\n"
|
|
|
|
|
<< beforeOpen.toString() << "\n"
|
|
|
|
|
<< afterClose.toString();
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_P(AudioEffectTest, DescriptorExistAndUnique) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
Descriptor desc;
|
|
|
|
|
|
|
|
|
|
auto descList = EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor);
|
|
|
|
|
std::set<Descriptor::Identity> idSet;
|
|
|
|
|
for (const auto& it : descList) {
|
|
|
|
|
auto& id = it.second;
|
|
|
|
|
auto& id = it.second.common.id;
|
|
|
|
|
EXPECT_EQ(0ul, idSet.count(id));
|
|
|
|
|
idSet.insert(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(effect, desc));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(getDescriptor(mEffect, desc));
|
|
|
|
|
EXPECT_EQ(1ul, idSet.count(desc.common.id));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// State testing.
|
|
|
|
|
// An effect instance is in INIT state by default after it was created.
|
|
|
|
|
TEST_P(AudioEffectTest, InitStateAfterCreation) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::INIT));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An effect instance transfer to IDLE state after IEffect.ASSERT_NO_FATAL_FAILURE(open().
|
|
|
|
|
TEST_P(AudioEffectTest, IdleStateAfterOpen) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An effect instance is in PROCESSING state after it receive an START command.
|
|
|
|
|
TEST_P(AudioEffectTest, ProcessingStateAfterStart) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An effect instance transfer to IDLE state after Command.Id.STOP in PROCESSING state.
|
|
|
|
|
TEST_P(AudioEffectTest, IdleStateAfterStop) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An effect instance transfer to IDLE state after Command.Id.RESET in PROCESSING state.
|
|
|
|
|
TEST_P(AudioEffectTest, IdleStateAfterReset) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An effect instance transfer to INIT after IEffect.ASSERT_NO_FATAL_FAILURE(close().
|
|
|
|
|
TEST_P(AudioEffectTest, InitStateAfterClose) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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(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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// An effect instance shouldn't accept any command before open.
|
|
|
|
|
TEST_P(AudioEffectTest, NoCommandAcceptedBeforeOpen) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No-op when receive STOP command in IDLE state.
|
|
|
|
|
TEST_P(AudioEffectTest, StopCommandInIdleStateNoOp) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// No-op when receive RESET command in IDLE state.
|
|
|
|
|
TEST_P(AudioEffectTest, ResetCommandInIdleStateNoOp) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Repeat START and STOP command.
|
|
|
|
|
TEST_P(AudioEffectTest, RepeatStartAndStop) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
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(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Repeat START and RESET command.
|
|
|
|
|
TEST_P(AudioEffectTest, RepeatStartAndReset) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
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(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Try to close an effect instance at PROCESSING state.
|
|
|
|
|
TEST_P(AudioEffectTest, CloseProcessingStateEffects) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
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(effect, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect, EX_ILLEGAL_STATE));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expect EX_ILLEGAL_STATE if the effect instance is not in a proper state to be destroyed.
|
|
|
|
|
TEST_P(AudioEffectTest, DestroyOpenEffects) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
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, effect, EX_ILLEGAL_STATE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect, EX_ILLEGAL_STATE));
|
|
|
|
|
|
|
|
|
|
// cleanup
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expect EX_ILLEGAL_STATE if the effect instance is not in a proper state to be destroyed.
|
|
|
|
|
TEST_P(AudioEffectTest, DestroyProcessingEffects) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
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, effect, EX_ILLEGAL_STATE));
|
|
|
|
|
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) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::INIT));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Parameter testing.
|
|
|
|
|
// Verify parameters pass in open can be successfully get.
|
|
|
|
|
TEST_P(AudioEffectTest, VerifyCommonParametersAfterOpen) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon();
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
|
|
|
|
|
Parameter get = Parameter(), expect = Parameter();
|
|
|
|
|
expect.set<Parameter::common>(common);
|
|
|
|
|
Parameter::Id id;
|
|
|
|
|
id.set<Parameter::Id::commonTag>(Parameter::common);
|
|
|
|
|
EXPECT_IS_OK(effect->getParameter(id, &get));
|
|
|
|
|
EXPECT_IS_OK(mEffect->getParameter(id, &get));
|
|
|
|
|
EXPECT_EQ(expect, get) << expect.toString() << " vs " << get.toString();
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify parameters pass in set can be successfully get.
|
|
|
|
|
TEST_P(AudioEffectTest, SetAndGetCommonParameter) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(mEffect));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
|
|
|
|
|
Parameter get = Parameter(), set = Parameter();
|
|
|
|
|
set.set<Parameter::common>(common);
|
|
|
|
|
EXPECT_IS_OK(effect->setParameter(set));
|
|
|
|
|
EXPECT_IS_OK(mEffect->setParameter(set));
|
|
|
|
|
|
|
|
|
|
Parameter::Id id;
|
|
|
|
|
id.set<Parameter::Id::commonTag>(Parameter::common);
|
|
|
|
|
EXPECT_IS_OK(effect->getParameter(id, &get));
|
|
|
|
|
EXPECT_IS_OK(mEffect->getParameter(id, &get));
|
|
|
|
|
EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify parameters set and get in PROCESSING state.
|
|
|
|
|
TEST_P(AudioEffectTest, SetAndGetParameterInProcessing) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
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 = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
|
|
|
|
|
Parameter get = Parameter(), set = Parameter();
|
|
|
|
|
set.set<Parameter::common>(common);
|
|
|
|
|
EXPECT_IS_OK(effect->setParameter(set));
|
|
|
|
|
EXPECT_IS_OK(mEffect->setParameter(set));
|
|
|
|
|
|
|
|
|
|
Parameter::Id id;
|
|
|
|
|
id.set<Parameter::Id::commonTag>(Parameter::common);
|
|
|
|
|
EXPECT_IS_OK(effect->getParameter(id, &get));
|
|
|
|
|
EXPECT_IS_OK(mEffect->getParameter(id, &get));
|
|
|
|
|
EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify parameters set and get in IDLE state.
|
|
|
|
|
TEST_P(AudioEffectTest, SetAndGetParameterInIdle) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
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 = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
|
|
|
|
|
Parameter get = Parameter(), set = Parameter();
|
|
|
|
|
set.set<Parameter::common>(common);
|
|
|
|
|
EXPECT_IS_OK(effect->setParameter(set));
|
|
|
|
|
EXPECT_IS_OK(mEffect->setParameter(set));
|
|
|
|
|
|
|
|
|
|
Parameter::Id id;
|
|
|
|
|
id.set<Parameter::Id::commonTag>(Parameter::common);
|
|
|
|
|
EXPECT_IS_OK(effect->getParameter(id, &get));
|
|
|
|
|
EXPECT_IS_OK(mEffect->getParameter(id, &get));
|
|
|
|
|
EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify Parameters kept after stop.
|
|
|
|
|
TEST_P(AudioEffectTest, SetAndGetParameterAfterStop) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
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 = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
|
|
|
|
|
Parameter get = Parameter(), set = Parameter();
|
|
|
|
|
set.set<Parameter::common>(common);
|
|
|
|
|
EXPECT_IS_OK(effect->setParameter(set));
|
|
|
|
|
EXPECT_IS_OK(mEffect->setParameter(set));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
Parameter::Id id;
|
|
|
|
|
id.set<Parameter::Id::commonTag>(Parameter::common);
|
|
|
|
|
EXPECT_IS_OK(effect->getParameter(id, &get));
|
|
|
|
|
EXPECT_IS_OK(mEffect->getParameter(id, &get));
|
|
|
|
|
EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify Parameters kept after reset.
|
|
|
|
|
TEST_P(AudioEffectTest, SetAndGetParameterAfterReset) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(mEffect));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */);
|
|
|
|
|
Parameter get = Parameter(), set = Parameter();
|
|
|
|
|
set.set<Parameter::common>(common);
|
|
|
|
|
EXPECT_IS_OK(effect->setParameter(set));
|
|
|
|
|
EXPECT_IS_OK(mEffect->setParameter(set));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::RESET));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
Parameter::Id id;
|
|
|
|
|
id.set<Parameter::Id::commonTag>(Parameter::common);
|
|
|
|
|
EXPECT_IS_OK(effect->getParameter(id, &get));
|
|
|
|
|
EXPECT_IS_OK(mEffect->getParameter(id, &get));
|
|
|
|
|
EXPECT_EQ(set, get) << set.toString() << " vs " << get.toString();
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Data processing test
|
|
|
|
|
// Send data to effects and expect it to be consumed by checking statusMQ.
|
|
|
|
|
TEST_P(AudioEffectTest, ConsumeDataInProcessingState) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
|
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
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(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
|
|
|
|
|
|
|
|
|
|
std::vector<float> buffer;
|
|
|
|
|
EffectHelper::allocateInputData(common, inputMQ, buffer);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ, buffer);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send data to effects and expect it to be consumed after effect restart.
|
|
|
|
|
TEST_P(AudioEffectTest, ConsumeDataAfterRestart) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
|
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
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(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
|
|
std::vector<float> buffer;
|
|
|
|
|
EffectHelper::allocateInputData(common, inputMQ, buffer);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ, buffer);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send data to IDLE effects and expect it to be consumed after effect start.
|
|
|
|
|
TEST_P(AudioEffectTest, SendDataAtIdleAndConsumeDataInProcessing) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
|
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
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;
|
|
|
|
|
EffectHelper::allocateInputData(common, inputMQ, buffer);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ, buffer);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
|
|
|
|
|
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send data multiple times.
|
|
|
|
|
TEST_P(AudioEffectTest, ProcessDataMultipleTimes) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
|
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
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;
|
|
|
|
|
EffectHelper::allocateInputData(common, inputMQ, buffer);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ, buffer);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
|
|
|
|
|
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
|
|
|
|
|
// expect no status and data after consume
|
|
|
|
@ -634,77 +635,81 @@ TEST_P(AudioEffectTest, ProcessDataMultipleTimes) {
|
|
|
|
|
// expect no status and data after consume
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send data to IDLE state effects and expect it not be consumed.
|
|
|
|
|
TEST_P(AudioEffectTest, NotConsumeDataInIdleState) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
|
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
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(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, 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));
|
|
|
|
|
|
|
|
|
|
std::vector<float> buffer;
|
|
|
|
|
EffectHelper::allocateInputData(common, inputMQ, buffer);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ, buffer);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::PROCESSING));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::START));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::PROCESSING));
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 1, outputMQ, buffer.size(), buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(effect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect, State::IDLE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(command(mEffect, CommandId::STOP));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(mEffect, State::IDLE));
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send data to closed effects and expect it not be consumed.
|
|
|
|
|
TEST_P(AudioEffectTest, NotConsumeDataByClosedEffect) {
|
|
|
|
|
std::shared_ptr<IEffect> effect;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
|
kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */);
|
|
|
|
|
IEffect::OpenEffectReturn ret;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(effect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, std::nullopt /* specific */, &ret, EX_NONE));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(close(mEffect));
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
EffectHelper::allocateInputData(common, inputMQ, buffer);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ, buffer);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ, 0, outputMQ, 0, buffer);
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, effect));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send data to multiple effects.
|
|
|
|
|
TEST_P(AudioEffectTest, ConsumeDataMultipleEffects) {
|
|
|
|
|
std::shared_ptr<IEffect> effect1, effect2;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mIdentity));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect1, mDescriptor));
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(create(mFactory, effect2, mDescriptor));
|
|
|
|
|
|
|
|
|
|
Parameter::Common common1 = EffectHelper::createParamCommon(
|
|
|
|
|
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
|
|
|
|
@ -721,8 +726,11 @@ TEST_P(AudioEffectTest, ConsumeDataMultipleEffects) {
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(expectState(effect2, State::PROCESSING));
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
std::vector<float> buffer1, buffer2;
|
|
|
|
|
EffectHelper::allocateInputData(common1, inputMQ1, buffer1);
|
|
|
|
@ -730,8 +738,11 @@ TEST_P(AudioEffectTest, ConsumeDataMultipleEffects) {
|
|
|
|
|
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());
|
|
|
|
|
EffectHelper::allocateInputData(common2, inputMQ2, buffer2);
|
|
|
|
|
EffectHelper::writeToFmq(inputMQ2, buffer2);
|
|
|
|
|
EffectHelper::readFromFmq(statusMQ2, 1, outputMQ2, buffer2.size(), buffer2);
|
|
|
|
@ -752,9 +763,11 @@ INSTANTIATE_TEST_SUITE_P(
|
|
|
|
|
::testing::Combine(testing::ValuesIn(
|
|
|
|
|
EffectFactoryHelper::getAllEffectDescriptors(IFactory::descriptor))),
|
|
|
|
|
[](const testing::TestParamInfo<AudioEffectTest::ParamType>& info) {
|
|
|
|
|
auto instance = std::get<PARAM_INSTANCE_NAME>(info.param);
|
|
|
|
|
std::string name = "TYPE_" + instance.second.type.toString() + "_UUID_" +
|
|
|
|
|
instance.second.uuid.toString();
|
|
|
|
|
auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
|
|
|
|
|
std::string name = "Implementor_" + descriptor.common.implementor + "_name_" +
|
|
|
|
|
descriptor.common.name + "_TYPE_" +
|
|
|
|
|
descriptor.common.id.type.toString() + "_UUID_" +
|
|
|
|
|
descriptor.common.id.uuid.toString();
|
|
|
|
|
std::replace_if(
|
|
|
|
|
name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
|
|
|
|
|
return name;
|
|
|
|
|