-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathcheck-src-rec.sh
More file actions
executable file
·117 lines (94 loc) · 3.86 KB
/
check-src-rec.sh
File metadata and controls
executable file
·117 lines (94 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
##
## Case Name: check-src-rec
## Preconditions:
## ffmpeg installed
## Description:
## Verify sample-rate conversion (SRC) for capture paths by playing a reference 48 kHz chirp and recording it at a variety of lower and higher sample rates.
## This ensures the capture pipeline correctly resamples incoming audio from a fixed playback sample rate to requested capture rates.
## Case steps:
## 1. Generate a 48 kHz stereo chirp signal using ffmpeg and store it in the test log directory.
## 2. For each sample rate under test, play the 48 kHz chirp and record using arecord at the target sample rate.
## 3. Save recorded files for each sample rate to the log directory for later inspection.
## 4. Analyze the recorded files to confirm the chirp content is present and resampling is performed without major artifacts.
## Expected result:
## - Playback and capture operations succeed for all tested sample rates.
## - A recorded file exists for each requested sample rate in the log directory.
## - Recorded files contain the expected chirp (no severe distortion or silence) and no pipeline errors are observed.
##
set -e
# It is pointless to perf component in HDMI pipeline, so filter out HDMI pipelines
# shellcheck disable=SC2034
NO_HDMI_MODE=true
# shellcheck source=case-lib/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")"/../case-lib/lib.sh
OPT_NAME['t']='tplg' OPT_DESC['t']='tplg file, default value is env TPLG: $''TPLG'
OPT_HAS_ARG['t']=1 OPT_VAL['t']="$TPLG"
OPT_NAME['p']='playback_device' OPT_DESC['p']='ALSA pcm playback device. Default: hw:0,2'
OPT_HAS_ARG['p']=1 OPT_VAL['p']='hw:0,2'
OPT_NAME['c']='capture_device' OPT_DESC['c']='ALSA pcm capture device. Default: hw:0,2'
OPT_HAS_ARG['c']=1 OPT_VAL['c']='hw:0,2'
OPT_NAME['s']='sof-logger' OPT_DESC['s']="Open sof-logger trace the data will store at $LOG_ROOT"
OPT_HAS_ARG['s']=0 OPT_VAL['s']=1
func_opt_parse_option "$@"
init_globals()
{
tplg=${OPT_VAL['t']}
playback_dev=${OPT_VAL['p']}
capture_dev=${OPT_VAL['c']}
sample_rates=("8000" "16000" "22050" "32000" "44100" "48000")
rec_opt="-f S16_LE -c 2 -d 7"
test_sound_filename=$HOME/Music/play.wav
all_result_files=()
}
run_tests()
{
dlogi "Generate 48 kHz chirp 0 - 20 kHz"
ffmpeg -loglevel error -y -f lavfi -i "aevalsrc='sin(2000*t*2*PI*t)':s=48000:d=5" -ac 2 "$test_sound_filename"
failures=0
set +e
for i in "${!sample_rates[@]}"
do
test_pass=true
sample_rate=${sample_rates[$i]}
dlogi "--------------- TEST $((i+1)): PLAY SAMPLE RATE 48000 Hz, RECORD IN $sample_rate Hz ---------------"
result_filename=$LOG_ROOT/rec_$sample_rate.wav
play_and_record "-D$capture_dev $rec_opt -r $sample_rate $result_filename" "-D$playback_dev $test_sound_filename"
if [ $? -eq 1 ]; then
test_pass=false
dlogi "TEST $((i+1)) FAIL: aplay/arecord failed, look for previous errors"
else
check_soundfile_for_glitches "$result_filename"
if [ $? -eq 1 ]; then
test_pass=false
dlogi "TEST $((i+1)) FAIL: Found glitch in the recording"
fi
fi
if [ "$test_pass" = true ]; then
dlogi "TEST $((i+1)) PASS: No issues found."
else
failures=$((failures+1))
fi
done
set -e
if [ "$failures" = 0 ]; then
dlogi "PASS: All testcases passed"
else
die "FAIL: $failures testcases failed"
fi
}
main()
{
init_globals
start_test
if [[ "$TPLG" != *nocodec* ]]; then
skip_test "Skipping: this test is supported only on NOCODEC platforms."
fi
logger_disabled || func_lib_start_log_collect
func_lib_check_sudo
func_pipeline_export "$tplg" "type:any"
run_tests
}
{
main "$@"; exit "$?"
}