Skip to content

Commit 27505f3

Browse files
test(cmocka, drc): add DRC process unit test
Add a process-level cmocka test for the DRC module. The new drc_process test follows the eq_iir_process harness (legacy process_audio_stream API): it builds a small libaudio, creates the DRC component through the full lifecycle (comp_new -> set_configuration -> prepare -> streaming) and pushes a chirp signal in S16/S24/S32.
1 parent 3347ddc commit 27505f3

3 files changed

Lines changed: 628 additions & 0 deletions

File tree

test/cmocka/src/audio/drc/CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,54 @@ cmocka_test(drc_math_test
1010
)
1111

1212
target_include_directories(drc_math_test PRIVATE ${PROJECT_SOURCE_DIR}/src/audio)
13+
14+
cmocka_test(drc_process
15+
drc_process.c
16+
)
17+
18+
target_include_directories(drc_process PRIVATE ${PROJECT_SOURCE_DIR}/src/audio)
19+
20+
# make small version of libaudio so we don't have to care
21+
# about unused missing references
22+
23+
add_compile_options(-DUNIT_TEST)
24+
25+
add_library(audio_for_drc STATIC
26+
${PROJECT_SOURCE_DIR}/src/audio/drc/drc.c
27+
${PROJECT_SOURCE_DIR}/src/audio/drc/drc_generic.c
28+
${PROJECT_SOURCE_DIR}/src/audio/drc/drc_math_generic.c
29+
${PROJECT_SOURCE_DIR}/src/audio/drc/drc_math_hifi3.c
30+
${PROJECT_SOURCE_DIR}/src/audio/drc/drc_log.c
31+
${PROJECT_SOURCE_DIR}/src/math/numbers.c
32+
${PROJECT_SOURCE_DIR}/src/math/exp_fcn.c
33+
${PROJECT_SOURCE_DIR}/src/math/exp_fcn_hifi.c
34+
${PROJECT_SOURCE_DIR}/src/math/lut_trig.c
35+
${PROJECT_SOURCE_DIR}/src/audio/module_adapter/module_adapter.c
36+
${PROJECT_SOURCE_DIR}/src/audio/module_adapter/module_adapter_ipc3.c
37+
${PROJECT_SOURCE_DIR}/src/audio/module_adapter/module/generic.c
38+
${PROJECT_SOURCE_DIR}/src/audio/buffers/comp_buffer.c
39+
${PROJECT_SOURCE_DIR}/src/audio/buffers/audio_buffer.c
40+
${PROJECT_SOURCE_DIR}/src/audio/source_api_helper.c
41+
${PROJECT_SOURCE_DIR}/src/audio/sink_api_helper.c
42+
${PROJECT_SOURCE_DIR}/src/audio/sink_source_utils.c
43+
${PROJECT_SOURCE_DIR}/src/audio/audio_stream.c
44+
${PROJECT_SOURCE_DIR}/src/audio/component.c
45+
${PROJECT_SOURCE_DIR}/src/audio/data_blob.c
46+
${PROJECT_SOURCE_DIR}/src/module/audio/source_api.c
47+
${PROJECT_SOURCE_DIR}/src/module/audio/sink_api.c
48+
${PROJECT_SOURCE_DIR}/src/ipc/ipc3/helper.c
49+
${PROJECT_SOURCE_DIR}/src/ipc/ipc-common.c
50+
${PROJECT_SOURCE_DIR}/src/ipc/ipc-helper.c
51+
${PROJECT_SOURCE_DIR}/src/lib/objpool.c
52+
${PROJECT_SOURCE_DIR}/test/cmocka/src/notifier_mocks.c
53+
${PROJECT_SOURCE_DIR}/src/audio/pipeline/pipeline-graph.c
54+
${PROJECT_SOURCE_DIR}/src/audio/pipeline/pipeline-params.c
55+
${PROJECT_SOURCE_DIR}/src/audio/pipeline/pipeline-schedule.c
56+
${PROJECT_SOURCE_DIR}/src/audio/pipeline/pipeline-stream.c
57+
${PROJECT_SOURCE_DIR}/src/audio/pipeline/pipeline-xrun.c
58+
)
59+
sof_append_relative_path_definitions(audio_for_drc)
60+
61+
target_link_libraries(audio_for_drc PRIVATE sof_options)
62+
63+
target_link_libraries(drc_process PRIVATE audio_for_drc)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2024 Intel Corporation.
4+
*
5+
* DRC configuration blobs for the process unit test. Generated from
6+
* tools/ctl/ipc4/drc/{passthrough,speaker_default}.txt (see
7+
* src/audio/drc/tune/sof_example_drc.m). Each array is a sof_abi_hdr
8+
* header followed by a struct sof_drc_config payload.
9+
*/
10+
11+
#ifndef CMOCKA_DRC_COEF_H
12+
#define CMOCKA_DRC_COEF_H
13+
14+
#include <stdint.h>
15+
16+
/* Pass-through configuration (params.enabled = 0) */
17+
static const uint32_t drc_coef_pass_2ch[35] = {
18+
0x00464f53, 0x00000000, 0x0000006c, 0x03013000,
19+
0x00000000, 0x00000000, 0x00000000, 0x00000000,
20+
0x0000006c, 0x00000000, 0x00000000, 0x00000000,
21+
0x00000000, 0x00000000, 0xe8000000, 0x1e000000,
22+
0x0c000000, 0x00624dd3, 0x0409c2b1, 0x05555555,
23+
0x001efa50, 0x00946055, 0xff6a987e, 0x01fec983,
24+
0x22474764, 0x01745617, 0x0071c71c, 0xff777777,
25+
0x001f77d8, 0x00000005, 0x00438000, 0x00047dd7,
26+
0x0025cea0, 0x00097dd7, 0x0000b5b1
27+
};
28+
29+
/* Enabled configuration, small speaker default (params.enabled = 1) */
30+
static const uint32_t drc_coef_enabled_2ch[35] = {
31+
0x00464f53, 0x00000000, 0x0000006c, 0x03013000,
32+
0x00000000, 0x00000000, 0x00000000, 0x00000000,
33+
0x0000006c, 0x00000000, 0x00000000, 0x00000000,
34+
0x00000000, 0x00000001, 0xe2000000, 0x14000000,
35+
0x0a000000, 0x00624dd3, 0x02061b8a, 0x06666666,
36+
0x00ba972f, 0x001e0c18, 0xffe04220, 0x0050f44e,
37+
0x08349f9a, 0x04d82cd3, 0x0071c71c, 0xff777777,
38+
0x001f77d8, 0x00000005, 0x00438000, 0x00047dd7,
39+
0x0025cea0, 0x00097dd7, 0x0000b5b1
40+
};
41+
42+
#endif /* CMOCKA_DRC_COEF_H */

0 commit comments

Comments
 (0)