-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtest-speaker.sh
More file actions
executable file
·77 lines (64 loc) · 2.58 KB
/
test-speaker.sh
File metadata and controls
executable file
·77 lines (64 loc) · 2.58 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
#!/bin/bash
##
## Case Name: test-speaker
## Preconditions:
## Wave file for each channel should be in /usr/share/sounds/alsa,
## eg, Front_Left.wav, Front_Right.wav, etc.
## Description:
## Test playback pipelines with speaker-test
## Case step:
## Iteratively run speaker-test on each playback pipeline
## Expect result:
## 1. speaker-test returns without error.
## 2. Waves are played through corresponding speaker, eg, you should only
## hear "front left" from the front left speaker.
##
# 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['l']='loop' OPT_DESC['l']='option of speaker-test'
OPT_HAS_ARG['l']=1 OPT_VAL['l']=3
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 "$@"
tplg=${OPT_VAL['t']}
start_test
save_alsa_state
logger_disabled || func_lib_start_log_collect
func_pipeline_export "$tplg" "type:playback"
tcnt=${OPT_VAL['l']}
setup_kernel_check_point
for idx in $(seq 0 $((PIPELINE_COUNT - 1)))
do
channel=$(func_pipeline_parse_value "$idx" channel)
rate=$(func_pipeline_parse_value "$idx" rate)
fmt=$(func_pipeline_parse_value "$idx" fmt)
dev=$(func_pipeline_parse_value "$idx" dev)
snd=$(func_pipeline_parse_value "$idx" snd)
#
# The default wav files for speaker-test are 48000Hz 16bit mono
# files. In this test, no alsa-lib plugin layer is used so the "wav" test
# method can be only be used if sampling rate and sample format
# match exactly. Channel count does NOT need to match, so we do not
# need to check for that here.
#
# Use "pink" test method for other audio configurations.
#
if [ "$rate" = "48000" ] && [ "$fmt" = "S16_LE" ]; then
sound_type="wav"
else
sound_type="pink"
fi
dlogc "speaker-test -D $dev -r $rate -c $channel -F $fmt -l $tcnt -t $sound_type -P 8"
# note -F has different semantics than in other alsa-utils, and speaker-test(1)
# man page does not cover this
speaker-test -D "$dev" -r "$rate" -c "$channel" -F "$fmt" -l "$tcnt" -t "$sound_type" -P 8 2>&1 |tee "$LOG_ROOT"/result_"$idx".txt
resultRet=${PIPESTATUS[0]}
if grep -nr -E "error|failed" "$LOG_ROOT"/result_"$idx".txt ||
[[ $resultRet -ne 0 ]]; then
func_lib_lsof_error_dump "$snd"
die "speaker test failed"
fi
done
sof-kernel-log-check.sh "$KERNEL_CHECKPOINT"