Modify the buffer size according to the framecounts
Bug: 305866207
Test: atest VtsHalDownmixTargetTest
atest VtsHalLoudnessEnhancerTargetTest
Change-Id: I448875e7d79ac766a882cc3a958fb54ef76265ce
diff --git a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
index 844a340..a1491e6 100644
--- a/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalDownmixTargetTest.cpp
@@ -96,8 +96,7 @@
Parameter::Specific specific = getDefaultParamSpecific();
Parameter::Common common = EffectHelper::createParamCommon(
0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
- kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */,
- inputChannelLayout,
+ kFrameCount /* iFrameCount */, kFrameCount /* oFrameCount */, inputChannelLayout,
AudioChannelLayout::make<AudioChannelLayout::layoutMask>(
AudioChannelLayout::LAYOUT_STEREO));
ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &mOpenEffectReturn, EX_NONE));
@@ -139,14 +138,14 @@
}
void setDataTestParams(int32_t layoutType) {
- mInputBuffer.resize(kBufferSize);
-
// Get the number of channels used
mInputChannelCount = getChannelCount(
AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layoutType));
+ mInputBufferSize = kFrameCount * mInputChannelCount;
+ mInputBuffer.resize(mInputBufferSize);
// In case of downmix, output is always configured to stereo layout.
- mOutputBufferSize = (mInputBuffer.size() / mInputChannelCount) * kOutputChannelCount;
+ mOutputBufferSize = kFrameCount * kOutputChannelCount;
mOutputBuffer.resize(mOutputBufferSize);
}
@@ -173,7 +172,12 @@
return true;
}
- static constexpr long kInputFrameCount = 100, kOutputFrameCount = 100;
+ static const long kFrameCount = 256;
+ static constexpr float kMaxDownmixSample = 1;
+ static constexpr int kOutputChannelCount = 2;
+ // Mask for layouts greater than MAX_INPUT_CHANNELS_SUPPORTED
+ static constexpr int32_t kMaxChannelMask =
+ ~((1 << ChannelMix<AUDIO_CHANNEL_OUT_STEREO>::MAX_INPUT_CHANNELS_SUPPORTED) - 1);
std::shared_ptr<IFactory> mFactory;
Descriptor mDescriptor;
std::shared_ptr<IEffect> mEffect;
@@ -183,12 +187,7 @@
std::vector<float> mOutputBuffer;
size_t mInputChannelCount;
size_t mOutputBufferSize;
- static constexpr size_t kBufferSize = 128;
- static constexpr float kMaxDownmixSample = 1;
- static constexpr int kOutputChannelCount = 2;
- // Mask for layouts greater than MAX_INPUT_CHANNELS_SUPPORTED
- static constexpr int32_t kMaxChannelMask =
- ~((1 << ChannelMix<AUDIO_CHANNEL_OUT_STEREO>::MAX_INPUT_CHANNELS_SUPPORTED) - 1);
+ size_t mInputBufferSize;
};
/**
@@ -401,9 +400,9 @@
void TearDown() override { TearDownDownmix(); }
void validateOutput() {
- ASSERT_EQ(kBufferSize, mInputBuffer.size());
- ASSERT_GE(kBufferSize, mOutputBufferSize);
- for (size_t i = 0, j = 0; i < kBufferSize && j < mOutputBufferSize;
+ ASSERT_EQ(mInputBufferSize, mInputBuffer.size());
+ ASSERT_GE(mInputBufferSize, mOutputBufferSize);
+ for (size_t i = 0, j = 0; i < mInputBufferSize && j < mOutputBufferSize;
i += mInputChannelCount, j += kOutputChannelCount) {
ASSERT_EQ(mOutputBuffer[j], mInputBuffer[i]);
ASSERT_EQ(mOutputBuffer[j + 1], mInputBuffer[i + 1]);