VtsHalTargetTest: Configure channel layout and generate input data
correctly
This commit includes multiple changes:
- Updated generateSineWave function to generate both mono and stereo data
- Moved the calculateMagnitude function to a common location, the EffectHelper
class and added support for both mono and stereo data
- Modified the createParamCommon function
- Moved some constants to a common location, EffectHelper.h
- Updated some test functions to add support for both mono and stereo
- Added a function in EffectHelper to validate pffft input size
- Added checks in calculateMagnitudeMono() function to validate
input and output buffer size
Bug: 305866207
Test: atest hardware/interfaces/audio/aidl/vts/
Change-Id: Ia68108ad79349559b5b12bd6574da79fb1e117f3
diff --git a/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp b/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp
index 3021370..c9c7172 100644
--- a/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp
+++ b/audio/aidl/vts/VtsHalVirtualizerTargetTest.cpp
@@ -94,7 +94,6 @@
}
}
- static constexpr int kDefaultChannelLayout = AudioChannelLayout::LAYOUT_STEREO;
static constexpr int kDurationMilliSec = 720;
static constexpr int kBufferSize = kSamplingFrequency * kDurationMilliSec / 1000;
int kChannelCount = getChannelCount(
@@ -159,14 +158,6 @@
ASSERT_NO_FATAL_FAILURE(TearDownVirtualizer());
}
- void generateInput(std::vector<float>& buffer) {
- if (mZeroInput) {
- std::fill(buffer.begin(), buffer.end(), 0);
- } else {
- generateSineWave(1000 /*Input Frequency*/, buffer);
- }
- }
-
static constexpr float kAbsError = 0.00001;
bool mZeroInput;
};
@@ -176,7 +167,11 @@
std::vector<float> output(kBufferSize);
std::vector<int> strengths = {250, 500, 750, 1000};
- generateInput(input);
+ if (mZeroInput) {
+ std::fill(input.begin(), input.end(), 0);
+ } else {
+ ASSERT_NO_FATAL_FAILURE(generateSineWave(1000 /*Input Frequency*/, input));
+ }
const float inputRmse =
audio_utils_compute_energy_mono(input.data(), AUDIO_FORMAT_PCM_FLOAT, input.size());