blob: ef77f4d51e1dde88425ea39d817bb05de4c08655 [file] [log] [blame]
Sham Rathod40f55bd2022-11-14 14:24:49 +05301/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mikhail Naganov872d4a62023-03-09 18:19:01 -080017#define LOG_TAG "VtsHalDownmixTargetTest"
18#include <android-base/logging.h>
19
Sneha Patilf533b502023-10-25 12:39:55 +053020#include <audio_utils/ChannelMix.h>
Sham Rathod40f55bd2022-11-14 14:24:49 +053021#include "EffectHelper.h"
22
23using namespace android;
24
Sneha Patilf533b502023-10-25 12:39:55 +053025using aidl::android::hardware::audio::common::getChannelCount;
Sham Rathod40f55bd2022-11-14 14:24:49 +053026using aidl::android::hardware::audio::effect::Descriptor;
27using aidl::android::hardware::audio::effect::Downmix;
Shunkai Yaof8be1ac2023-03-06 18:41:27 +000028using aidl::android::hardware::audio::effect::getEffectTypeUuidDownmix;
Sham Rathod40f55bd2022-11-14 14:24:49 +053029using aidl::android::hardware::audio::effect::IEffect;
30using aidl::android::hardware::audio::effect::IFactory;
Sham Rathod40f55bd2022-11-14 14:24:49 +053031using aidl::android::hardware::audio::effect::Parameter;
Sneha Patilf533b502023-10-25 12:39:55 +053032using android::audio_utils::channels::ChannelMix;
Jaideep Sharma74498412023-09-13 15:25:25 +053033using android::hardware::audio::common::testing::detail::TestExecutionTracer;
Sham Rathod40f55bd2022-11-14 14:24:49 +053034
Shunkai Yao6b7784e2024-01-03 18:27:45 +000035// minimal HAL interface version to run downmix data path test
36constexpr int32_t kMinDataTestHalVersion = 2;
37
Sham Rathod40f55bd2022-11-14 14:24:49 +053038// Testing for enum values
Sneha Patilf533b502023-10-25 12:39:55 +053039static const std::vector<Downmix::Type> kTypeValues = {ndk::enum_range<Downmix::Type>().begin(),
40 ndk::enum_range<Downmix::Type>().end()};
Sham Rathod40f55bd2022-11-14 14:24:49 +053041
Sneha Patilf533b502023-10-25 12:39:55 +053042// Testing for supported layouts from AudioChannelLayout.h
43static const std::vector<int32_t> kLayoutValues = {
44 AudioChannelLayout::LAYOUT_STEREO, AudioChannelLayout::LAYOUT_2POINT1,
45 AudioChannelLayout::LAYOUT_TRI, AudioChannelLayout::LAYOUT_TRI_BACK,
46 AudioChannelLayout::LAYOUT_3POINT1, AudioChannelLayout::LAYOUT_2POINT0POINT2,
47 AudioChannelLayout::LAYOUT_2POINT1POINT2, AudioChannelLayout::LAYOUT_3POINT0POINT2,
48 AudioChannelLayout::LAYOUT_3POINT1POINT2, AudioChannelLayout::LAYOUT_QUAD,
49 AudioChannelLayout::LAYOUT_QUAD_SIDE, AudioChannelLayout::LAYOUT_SURROUND,
50 AudioChannelLayout::LAYOUT_PENTA, AudioChannelLayout::LAYOUT_5POINT1,
51 AudioChannelLayout::LAYOUT_5POINT1_SIDE, AudioChannelLayout::LAYOUT_5POINT1POINT2,
52 AudioChannelLayout::LAYOUT_5POINT1POINT4, AudioChannelLayout::LAYOUT_6POINT1,
53 AudioChannelLayout::LAYOUT_7POINT1, AudioChannelLayout::LAYOUT_7POINT1POINT2,
54 AudioChannelLayout::LAYOUT_7POINT1POINT4, AudioChannelLayout::LAYOUT_9POINT1POINT4,
55 AudioChannelLayout::LAYOUT_9POINT1POINT6, AudioChannelLayout::LAYOUT_13POINT_360RA,
56 AudioChannelLayout::LAYOUT_22POINT2};
57
58static const std::vector<int32_t> kChannels = {
59 AudioChannelLayout::CHANNEL_FRONT_LEFT,
60 AudioChannelLayout::CHANNEL_FRONT_RIGHT,
61 AudioChannelLayout::CHANNEL_FRONT_CENTER,
62 AudioChannelLayout::CHANNEL_LOW_FREQUENCY,
63 AudioChannelLayout::CHANNEL_BACK_LEFT,
64 AudioChannelLayout::CHANNEL_BACK_RIGHT,
65 AudioChannelLayout::CHANNEL_BACK_CENTER,
66 AudioChannelLayout::CHANNEL_SIDE_LEFT,
67 AudioChannelLayout::CHANNEL_SIDE_RIGHT,
68 AudioChannelLayout::CHANNEL_FRONT_LEFT_OF_CENTER,
69 AudioChannelLayout::CHANNEL_FRONT_RIGHT_OF_CENTER,
70 AudioChannelLayout::CHANNEL_TOP_CENTER,
71 AudioChannelLayout::CHANNEL_TOP_FRONT_LEFT,
72 AudioChannelLayout::CHANNEL_TOP_FRONT_CENTER,
73 AudioChannelLayout::CHANNEL_TOP_FRONT_RIGHT,
74 AudioChannelLayout::CHANNEL_TOP_BACK_LEFT,
75 AudioChannelLayout::CHANNEL_TOP_BACK_CENTER,
76 AudioChannelLayout::CHANNEL_TOP_BACK_RIGHT,
77 AudioChannelLayout::CHANNEL_TOP_SIDE_LEFT,
78 AudioChannelLayout::CHANNEL_TOP_SIDE_RIGHT,
79 AudioChannelLayout::CHANNEL_BOTTOM_FRONT_LEFT,
80 AudioChannelLayout::CHANNEL_BOTTOM_FRONT_CENTER,
81 AudioChannelLayout::CHANNEL_BOTTOM_FRONT_RIGHT,
82 AudioChannelLayout::CHANNEL_LOW_FREQUENCY_2,
83 AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT,
84 AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT,
85};
86
87class DownmixEffectHelper : public EffectHelper {
Sham Rathod40f55bd2022-11-14 14:24:49 +053088 public:
Sneha Patilf533b502023-10-25 12:39:55 +053089 void SetUpDownmix(int32_t inputBufferLayout = AudioChannelLayout::LAYOUT_STEREO) {
Sham Rathod40f55bd2022-11-14 14:24:49 +053090 ASSERT_NE(nullptr, mFactory);
91 ASSERT_NO_FATAL_FAILURE(create(mFactory, mEffect, mDescriptor));
92
Sneha Patilf533b502023-10-25 12:39:55 +053093 AudioChannelLayout inputChannelLayout =
94 AudioChannelLayout::make<AudioChannelLayout::layoutMask>(inputBufferLayout);
95
Sham Rathod40f55bd2022-11-14 14:24:49 +053096 Parameter::Specific specific = getDefaultParamSpecific();
97 Parameter::Common common = EffectHelper::createParamCommon(
98 0 /* session */, 1 /* ioHandle */, 44100 /* iSampleRate */, 44100 /* oSampleRate */,
Sneha Patilf533b502023-10-25 12:39:55 +053099 kInputFrameCount /* iFrameCount */, kOutputFrameCount /* oFrameCount */,
100 inputChannelLayout);
101 ASSERT_NO_FATAL_FAILURE(open(mEffect, common, specific, &mOpenEffectReturn, EX_NONE));
Sham Rathod40f55bd2022-11-14 14:24:49 +0530102 ASSERT_NE(nullptr, mEffect);
103 }
104
Sneha Patilf533b502023-10-25 12:39:55 +0530105 void TearDownDownmix() {
Sham Rathod40f55bd2022-11-14 14:24:49 +0530106 ASSERT_NO_FATAL_FAILURE(close(mEffect));
107 ASSERT_NO_FATAL_FAILURE(destroy(mFactory, mEffect));
Sneha Patilf533b502023-10-25 12:39:55 +0530108 mOpenEffectReturn = IEffect::OpenEffectReturn{};
Sham Rathod40f55bd2022-11-14 14:24:49 +0530109 }
110
Sneha Patilf533b502023-10-25 12:39:55 +0530111 Parameter createDownmixParam(Downmix::Type type) {
112 return Parameter::make<Parameter::specific>(
113 Parameter::Specific::make<Parameter::Specific::downmix>(
114 Downmix::make<Downmix::type>(type)));
115 }
116 void setParameters(Downmix::Type type) {
117 // set parameter
118 auto param = createDownmixParam(type);
119 EXPECT_STATUS(EX_NONE, mEffect->setParameter(param)) << param.toString();
Sham Rathod40f55bd2022-11-14 14:24:49 +0530120 }
121
Sneha Patilf533b502023-10-25 12:39:55 +0530122 void validateParameters(Downmix::Type type) {
123 auto leId = Downmix::Id::make<Downmix::Id::commonTag>(Downmix::Tag(Downmix::type));
124 auto id = Parameter::Id::make<Parameter::Id::downmixTag>(leId);
125 // get parameter
126 Parameter getParam;
127 EXPECT_STATUS(EX_NONE, mEffect->getParameter(id, &getParam));
128 auto expectedParam = createDownmixParam(type);
129 EXPECT_EQ(expectedParam, getParam) << "\nexpectedParam:" << expectedParam.toString()
130 << "\ngetParam:" << getParam.toString();
Sham Rathod40f55bd2022-11-14 14:24:49 +0530131 }
132
133 Parameter::Specific getDefaultParamSpecific() {
134 Downmix dm = Downmix::make<Downmix::type>(Downmix::Type::STRIP);
135 Parameter::Specific specific = Parameter::Specific::make<Parameter::Specific::downmix>(dm);
136 return specific;
137 }
138
Sneha Patilf533b502023-10-25 12:39:55 +0530139 void setDataTestParams(int32_t layoutType) {
140 mInputBuffer.resize(kBufferSize);
Sneha Patilf533b502023-10-25 12:39:55 +0530141
142 // Get the number of channels used
143 mInputChannelCount = getChannelCount(
144 AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layoutType));
145
146 // In case of downmix, output is always configured to stereo layout.
147 mOutputBufferSize = (mInputBuffer.size() / mInputChannelCount) * kOutputChannelCount;
Shunkai Yao1319e982024-01-11 00:39:13 +0000148 mOutputBuffer.resize(mOutputBufferSize);
Sneha Patilf533b502023-10-25 12:39:55 +0530149 }
150
151 // Generate mInputBuffer values between -kMaxDownmixSample to kMaxDownmixSample
152 void generateInputBuffer(size_t position, bool isStrip) {
153 size_t increment;
154 if (isStrip)
155 // Fill input at all the channels
156 increment = 1;
157 else
158 // Fill input at only one channel
159 increment = mInputChannelCount;
160
161 for (size_t i = position; i < mInputBuffer.size(); i += increment) {
162 mInputBuffer[i] =
163 ((static_cast<float>(std::rand()) / RAND_MAX) * 2 - 1) * kMaxDownmixSample;
164 }
165 }
166
167 bool isLayoutValid(int32_t inputLayout) {
168 if (inputLayout & kMaxChannelMask) {
169 return false;
170 }
171 return true;
172 }
173
174 static constexpr long kInputFrameCount = 100, kOutputFrameCount = 100;
175 std::shared_ptr<IFactory> mFactory;
176 Descriptor mDescriptor;
177 std::shared_ptr<IEffect> mEffect;
178 IEffect::OpenEffectReturn mOpenEffectReturn;
179
180 std::vector<float> mInputBuffer;
181 std::vector<float> mOutputBuffer;
182 size_t mInputChannelCount;
183 size_t mOutputBufferSize;
184 static constexpr size_t kBufferSize = 128;
185 static constexpr float kMaxDownmixSample = 1;
186 static constexpr int kOutputChannelCount = 2;
187 // Mask for layouts greater than MAX_INPUT_CHANNELS_SUPPORTED
188 static constexpr int32_t kMaxChannelMask =
189 ~((1 << ChannelMix<AUDIO_CHANNEL_OUT_STEREO>::MAX_INPUT_CHANNELS_SUPPORTED) - 1);
190};
191
192/**
193 * Here we focus on specific parameter checking, general IEffect interfaces testing performed in
194 * VtsAudioEffectTargetTest.
195 */
196enum ParamName { PARAM_INSTANCE_NAME, PARAM_TYPE };
197
198using DownmixParamTestParam =
199 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, Downmix::Type>;
200
201class DownmixParamTest : public ::testing::TestWithParam<DownmixParamTestParam>,
202 public DownmixEffectHelper {
203 public:
204 DownmixParamTest() : mParamType(std::get<PARAM_TYPE>(GetParam())) {
205 std::tie(mFactory, mDescriptor) = std::get<PARAM_INSTANCE_NAME>(GetParam());
206 }
207
208 void SetUp() override { SetUpDownmix(); }
209
210 void TearDown() override { TearDownDownmix(); }
211
212 const Downmix::Type mParamType;
Sham Rathod40f55bd2022-11-14 14:24:49 +0530213};
214
215TEST_P(DownmixParamTest, SetAndGetType) {
Sneha Patilf533b502023-10-25 12:39:55 +0530216 ASSERT_NO_FATAL_FAILURE(setParameters(mParamType));
217 ASSERT_NO_FATAL_FAILURE(validateParameters(mParamType));
218}
219
220enum FoldParamName { FOLD_INSTANCE_NAME, FOLD_INPUT_LAYOUT, FOLD_TEST_CHANNEL };
221
222using DownmixDataTestParamFold =
223 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t>;
224
225class DownmixFoldDataTest : public ::testing::TestWithParam<DownmixDataTestParamFold>,
226 public DownmixEffectHelper {
227 public:
228 DownmixFoldDataTest() : mInputChannelLayout(std::get<FOLD_INPUT_LAYOUT>(GetParam())) {
229 std::tie(mFactory, mDescriptor) = std::get<FOLD_INSTANCE_NAME>(GetParam());
230 }
231
232 void SetUp() override {
Shunkai Yao50e478b2024-03-14 01:54:58 +0000233 SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
Sneha Patilf533b502023-10-25 12:39:55 +0530234 SetUpDownmix(mInputChannelLayout);
Shunkai Yao6b7784e2024-01-03 18:27:45 +0000235 if (int32_t version;
236 mEffect->getInterfaceVersion(&version).isOk() && version < kMinDataTestHalVersion) {
237 GTEST_SKIP() << "Skipping the data test for version: " << version << "\n";
238 }
Sneha Patilf533b502023-10-25 12:39:55 +0530239 if (!isLayoutValid(mInputChannelLayout)) {
240 GTEST_SKIP() << "Layout not supported \n";
241 }
242 setDataTestParams(mInputChannelLayout);
243 }
244
Shunkai Yao50e478b2024-03-14 01:54:58 +0000245 void TearDown() override {
246 SKIP_TEST_IF_DATA_UNSUPPORTED(mDescriptor.common.flags);
247 TearDownDownmix();
248 }
Sneha Patilf533b502023-10-25 12:39:55 +0530249
250 void checkAtLeft(int32_t position) {
251 for (size_t i = 0, j = position; i < mOutputBufferSize;
252 i += kOutputChannelCount, j += mInputChannelCount) {
253 // Validate Left channel has audio
254 if (mInputBuffer[j] != 0) {
255 ASSERT_NE(mOutputBuffer[i], 0);
256 } else {
257 // No change in output when input is 0
258 ASSERT_EQ(mOutputBuffer[i], mInputBuffer[j]);
259 }
260 // Validate Right channel has no audio
261 ASSERT_EQ(mOutputBuffer[i + 1], 0);
262 }
263 }
264
265 void checkAtRight(int32_t position) {
266 for (size_t i = 0, j = position; i < mOutputBufferSize;
267 i += kOutputChannelCount, j += mInputChannelCount) {
268 // Validate Left channel has no audio
Shunkai Yao1319e982024-01-11 00:39:13 +0000269 ASSERT_EQ(mOutputBuffer[i], 0) << " at " << i;
Sneha Patilf533b502023-10-25 12:39:55 +0530270 // Validate Right channel has audio
271 if (mInputBuffer[j] != 0) {
Shunkai Yao1319e982024-01-11 00:39:13 +0000272 ASSERT_NE(mOutputBuffer[i + 1], 0) << " at " << i;
Sneha Patilf533b502023-10-25 12:39:55 +0530273 } else {
274 // No change in output when input is 0
Shunkai Yao1319e982024-01-11 00:39:13 +0000275 ASSERT_EQ(mOutputBuffer[i + 1], mInputBuffer[j]) << " at " << i;
Sneha Patilf533b502023-10-25 12:39:55 +0530276 }
277 }
278 }
279
280 void checkAtCenter(size_t position) {
281 for (size_t i = 0, j = position; i < mOutputBufferSize;
282 i += kOutputChannelCount, j += mInputChannelCount) {
283 // Validate both channels have audio
284 if (mInputBuffer[j] != 0) {
285 ASSERT_NE(mOutputBuffer[i], 0);
286 ASSERT_NE(mOutputBuffer[i + 1], 0);
287
288 } else {
289 // No change in output when input is 0
290 ASSERT_EQ(mOutputBuffer[i], mInputBuffer[j]);
291 ASSERT_EQ(mOutputBuffer[i + 1], mInputBuffer[j]);
292 }
293 }
294 }
295
296 void validateOutput(int32_t channel, size_t position) {
297 switch (channel) {
298 case AudioChannelLayout::CHANNEL_FRONT_LEFT:
299 case AudioChannelLayout::CHANNEL_BACK_LEFT:
300 case AudioChannelLayout::CHANNEL_SIDE_LEFT:
301 case AudioChannelLayout::CHANNEL_TOP_FRONT_LEFT:
302 case AudioChannelLayout::CHANNEL_BOTTOM_FRONT_LEFT:
303 case AudioChannelLayout::CHANNEL_TOP_BACK_LEFT:
304 case AudioChannelLayout::CHANNEL_FRONT_WIDE_LEFT:
305 case AudioChannelLayout::CHANNEL_TOP_SIDE_LEFT:
306 checkAtLeft(position);
307 break;
308
309 case AudioChannelLayout::CHANNEL_FRONT_RIGHT:
310 case AudioChannelLayout::CHANNEL_BACK_RIGHT:
311 case AudioChannelLayout::CHANNEL_SIDE_RIGHT:
312 case AudioChannelLayout::CHANNEL_TOP_FRONT_RIGHT:
313 case AudioChannelLayout::CHANNEL_BOTTOM_FRONT_RIGHT:
314 case AudioChannelLayout::CHANNEL_TOP_BACK_RIGHT:
315 case AudioChannelLayout::CHANNEL_FRONT_WIDE_RIGHT:
316 case AudioChannelLayout::CHANNEL_TOP_SIDE_RIGHT:
317 case AudioChannelLayout::CHANNEL_LOW_FREQUENCY_2:
318 checkAtRight(position);
319 break;
320
321 case AudioChannelLayout::CHANNEL_FRONT_CENTER:
322 case AudioChannelLayout::CHANNEL_BACK_CENTER:
323 case AudioChannelLayout::CHANNEL_TOP_FRONT_CENTER:
324 case AudioChannelLayout::CHANNEL_BOTTOM_FRONT_CENTER:
325 case AudioChannelLayout::CHANNEL_FRONT_LEFT_OF_CENTER:
326 case AudioChannelLayout::CHANNEL_FRONT_RIGHT_OF_CENTER:
327 case AudioChannelLayout::CHANNEL_TOP_CENTER:
328 case AudioChannelLayout::CHANNEL_TOP_BACK_CENTER:
329 checkAtCenter(position);
330 break;
331
332 case AudioChannelLayout::CHANNEL_LOW_FREQUENCY:
333 // If CHANNEL_LOW_FREQUENCY_2 is supported
334 if (mInputChannelLayout & AudioChannelLayout::CHANNEL_LOW_FREQUENCY_2) {
335 // Validate that only Left channel has audio
336 checkAtLeft(position);
337 } else {
338 // Validate that both channels have audio
339 checkAtCenter(position);
340 }
341 break;
342 }
343 }
344
345 std::set<int32_t> getInputChannelLayouts() {
346 std::set<int32_t> supportedChannels;
347 for (int32_t channel : kChannels) {
348 if ((mInputChannelLayout & channel) == channel) {
349 supportedChannels.insert(channel);
350 }
351 }
352 return supportedChannels;
353 }
354
355 int32_t mInputChannelLayout;
356};
357
358TEST_P(DownmixFoldDataTest, DownmixProcessData) {
359 // Set FOLD type parameter
360 ASSERT_NO_FATAL_FAILURE(setParameters(Downmix::Type::FOLD));
361
362 // Get all the channels from input layout
363 std::set<int32_t> supportedChannels = getInputChannelLayouts();
364
365 for (int32_t channel : supportedChannels) {
366 size_t position = std::distance(supportedChannels.begin(), supportedChannels.find(channel));
367 generateInputBuffer(position, false /*isStripe*/);
368 ASSERT_NO_FATAL_FAILURE(
369 processAndWriteToOutput(mInputBuffer, mOutputBuffer, mEffect, &mOpenEffectReturn));
370 validateOutput(channel, position);
371 std::fill(mInputBuffer.begin(), mInputBuffer.end(), 0);
372 }
373}
374
375enum StripParamName { STRIP_INSTANCE_NAME, STRIP_INPUT_LAYOUT };
376
377using DownmixStripDataTestParam =
378 std::tuple<std::pair<std::shared_ptr<IFactory>, Descriptor>, int32_t>;
379
380class DownmixStripDataTest : public ::testing::TestWithParam<DownmixStripDataTestParam>,
381 public DownmixEffectHelper {
382 public:
383 DownmixStripDataTest() : mInputChannelLayout(std::get<STRIP_INPUT_LAYOUT>(GetParam())) {
384 std::tie(mFactory, mDescriptor) = std::get<STRIP_INSTANCE_NAME>(GetParam());
385 }
386
387 void SetUp() override {
388 SetUpDownmix(mInputChannelLayout);
Shunkai Yao6b7784e2024-01-03 18:27:45 +0000389 if (int32_t version;
390 mEffect->getInterfaceVersion(&version).isOk() && version < kMinDataTestHalVersion) {
391 GTEST_SKIP() << "Skipping the data test for version: " << version << "\n";
392 }
Sneha Patilf533b502023-10-25 12:39:55 +0530393 if (!isLayoutValid(mInputChannelLayout)) {
394 GTEST_SKIP() << "Layout not supported \n";
395 }
396 setDataTestParams(mInputChannelLayout);
397 }
398
399 void TearDown() override { TearDownDownmix(); }
400
401 void validateOutput() {
402 ASSERT_EQ(kBufferSize, mInputBuffer.size());
403 ASSERT_GE(kBufferSize, mOutputBufferSize);
404 for (size_t i = 0, j = 0; i < kBufferSize && j < mOutputBufferSize;
405 i += mInputChannelCount, j += kOutputChannelCount) {
406 ASSERT_EQ(mOutputBuffer[j], mInputBuffer[i]);
407 ASSERT_EQ(mOutputBuffer[j + 1], mInputBuffer[i + 1]);
408 }
Sneha Patilf533b502023-10-25 12:39:55 +0530409 }
410
411 int32_t mInputChannelLayout;
412};
413
414TEST_P(DownmixStripDataTest, DownmixProcessData) {
415 // Set STRIP type parameter
416 ASSERT_NO_FATAL_FAILURE(setParameters(Downmix::Type::STRIP));
417
418 // Generate input buffer, call process and compare outputs
419 generateInputBuffer(0 /*position*/, true /*isStripe*/);
420 ASSERT_NO_FATAL_FAILURE(
421 processAndWriteToOutput(mInputBuffer, mOutputBuffer, mEffect, &mOpenEffectReturn));
422 validateOutput();
Sham Rathod40f55bd2022-11-14 14:24:49 +0530423}
424
425INSTANTIATE_TEST_SUITE_P(
426 DownmixTest, DownmixParamTest,
427 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
Shunkai Yaof8be1ac2023-03-06 18:41:27 +0000428 IFactory::descriptor, getEffectTypeUuidDownmix())),
Sham Rathod40f55bd2022-11-14 14:24:49 +0530429 testing::ValuesIn(kTypeValues)),
430 [](const testing::TestParamInfo<DownmixParamTest::ParamType>& info) {
431 auto descriptor = std::get<PARAM_INSTANCE_NAME>(info.param).second;
432 std::string type = std::to_string(static_cast<int>(std::get<PARAM_TYPE>(info.param)));
Shunkai Yao6b7784e2024-01-03 18:27:45 +0000433 std::string name = getPrefix(descriptor) + "_type_" + type;
Sham Rathod40f55bd2022-11-14 14:24:49 +0530434 std::replace_if(
435 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
436 return name;
437 });
438
439GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DownmixParamTest);
440
Sneha Patilf533b502023-10-25 12:39:55 +0530441INSTANTIATE_TEST_SUITE_P(
442 DownmixTest, DownmixFoldDataTest,
443 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
444 IFactory::descriptor, getEffectTypeUuidDownmix())),
445 testing::ValuesIn(kLayoutValues)),
446 [](const testing::TestParamInfo<DownmixFoldDataTest::ParamType>& info) {
447 auto descriptor = std::get<FOLD_INSTANCE_NAME>(info.param).second;
448 std::string layout = std::to_string(std::get<FOLD_INPUT_LAYOUT>(info.param));
Shunkai Yao6b7784e2024-01-03 18:27:45 +0000449 std::string name = getPrefix(descriptor) + "_fold_layout_" + layout;
Sneha Patilf533b502023-10-25 12:39:55 +0530450 std::replace_if(
451 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
452 return name;
453 });
454
455GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DownmixFoldDataTest);
456
457INSTANTIATE_TEST_SUITE_P(
458 DownmixTest, DownmixStripDataTest,
459 ::testing::Combine(testing::ValuesIn(EffectFactoryHelper::getAllEffectDescriptors(
460 IFactory::descriptor, getEffectTypeUuidDownmix())),
461 testing::ValuesIn(kLayoutValues)),
462 [](const testing::TestParamInfo<DownmixStripDataTest::ParamType>& info) {
463 auto descriptor = std::get<STRIP_INSTANCE_NAME>(info.param).second;
464 std::string layout =
465 std::to_string(static_cast<int>(std::get<STRIP_INPUT_LAYOUT>(info.param)));
Shunkai Yao6b7784e2024-01-03 18:27:45 +0000466 std::string name = getPrefix(descriptor) + "_strip_layout_" + layout;
Sneha Patilf533b502023-10-25 12:39:55 +0530467 std::replace_if(
468 name.begin(), name.end(), [](const char c) { return !std::isalnum(c); }, '_');
469 return name;
470 });
471
472GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DownmixStripDataTest);
473
Sham Rathod40f55bd2022-11-14 14:24:49 +0530474int main(int argc, char** argv) {
475 ::testing::InitGoogleTest(&argc, argv);
Jaideep Sharma74498412023-09-13 15:25:25 +0530476 ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
Sham Rathod40f55bd2022-11-14 14:24:49 +0530477 ABinderProcess_setThreadPoolMaxThreadCount(1);
478 ABinderProcess_startThreadPool();
479 return RUN_ALL_TESTS();
480}