2020
2121set -e
2222
23+ PIPEWIRE_OUTPUTS=(" Speaker" " Headphones" " HDMI" " Stereo" )
24+ PIPEWIRE_INPUTS=(" Digital Microphone" " DMIC" " Headset Microphone" " SoundWire microphone" " Stereo" )
25+
2326# It is pointless to perf component in HDMI pipeline, so filter out HDMI pipelines
2427# shellcheck disable=SC2034
2528NO_HDMI_MODE=true
@@ -41,52 +44,112 @@ func_opt_parse_option "$@"
4144tplg=${OPT_VAL['t']}
4245duration=${OPT_VAL['d']}
4346
44- start_test
45- logger_disabled || func_lib_start_log_collect
46-
47- setup_kernel_check_point
48- func_lib_check_sudo
49- func_pipeline_export " $tplg " " type:any"
50-
51- aplay_num=0
52- arecord_num=0
53-
54- for idx in $( seq 0 $(( PIPELINE_COUNT - 1 )) )
55- do
56- channel=$( func_pipeline_parse_value " $idx " channel)
57- rate=$( func_pipeline_parse_value " $idx " rate)
58- dev=$( func_pipeline_parse_value " $idx " dev)
59- pcm=$( func_pipeline_parse_value " $idx " pcm)
60- type=$( func_pipeline_parse_value " $idx " type)
61-
62- # Currently, copier will convert bit depth to S32_LE despite what bit depth
63- # is used in aplay, so make S32_LE as base bit depth for performance analysis.
64- fmt=S32_LE
65-
66- dlogi " Running (PCM: $pcm [$dev ]<$type >) in background"
67- if [ " $type " == " playback" ]; then
68- aplay_opts -D " $dev " -c " $channel " -r " $rate " -f " $fmt " -d " $duration " /dev/zero -q &
69- aplay_num=$(( aplay_num+ 1 ))
70- else
71- arecord_opts -D " $dev " -c " $channel " -r " $rate " -f " $fmt " -d " $duration " /dev/null -q &
72- arecord_num=$(( arecord_num+ 1 ))
73- fi
74- done
75-
76- sleep 1 # waiting stable streaming of aplay/arecord
77- dlogi " Number of aplay/arecord process started: $aplay_num , $arecord_num "
7847
79- real_aplay_num=$( ps --no-headers -C aplay | wc -l)
80- real_arecord_num=$( ps --no-headers -C arecord | wc -l)
81- if [ " $real_aplay_num " != " $aplay_num " ] || [ " $real_arecord_num " != " $arecord_num " ];
82- then
83- dlogi " Number of aplay/arecord process running: $real_aplay_num , $real_arecord_num "
84- die " aplay/arecord process exit unexpectedly"
85- fi
48+ # run aplay for all sink types given as a parameter and save the number of started aplay processes
49+ run_aplays ()
50+ {
51+ local sinks=(" $@ " )
8652
87- dlogi " Waiting for aplay/arecord process to exit"
88- sleep $(( duration + 2 ))
53+ for sink_type in " ${sinks[@]} "
54+ do
55+ sink_id=$( get_id_of_pipewire_endpoint " $sink_type " )
56+ if [ -z " $sink_id " ]; then
57+ dlogi " No $sink_type found, skipping to the next one"
58+ continue
59+ fi
60+ dlogi " Setting default sink to $sink_id : $sink_type "
61+ wpctl set-default " $sink_id "
62+ aplay_opts -D pipewire /dev/zero -q &
63+ aplay_num=$(( aplay_num+ 1 ))
64+ done
65+ }
66+
67+ # run arecord for all source types given as a parameter and save the number of started arecord processes
68+ run_arecords ()
69+ {
70+ local sources=(" $@ " )
71+
72+ for source_type in " ${sources[@]} "
73+ do
74+ source_id=$( get_id_of_pipewire_endpoint " $source_type " )
75+ if [ -z " $source_id " ]; then
76+ dlogi " No $source_type found, skipping to the next one"
77+ continue
78+ fi
79+ dlogi " Setting default source to $source_id : $source_type "
80+ wpctl set-default " $source_id "
81+ arecord_opts -D pipewire /dev/null -q &
82+ arecord_num=$(( arecord_num+ 1 ))
83+ done
84+ }
85+
86+ main ()
87+ {
88+ start_test
89+ logger_disabled || func_lib_start_log_collect
90+
91+ setup_kernel_check_point
92+ func_lib_check_sudo
93+ func_pipeline_export " $tplg " " type:any"
94+
95+ aplay_num=0
96+ arecord_num=0
97+
98+ if [ " $SOF_TEST_PIPEWIRE " == true ]; then
99+
100+ dlogi " Running aplays"
101+ run_aplays " ${PIPEWIRE_OUTPUTS[@]} "
102+ dlogi " Running arecords"
103+ run_arecords " ${PIPEWIRE_INPUTS[@]} "
104+
105+ if [ " $aplay_num " == 0 ] && [ " $arecord_num " == 0 ]; then
106+ skip_test " No sinks/sources to be tested found, skipping test"
107+ fi
89108
90- # Enable performance analysis
91- # shellcheck disable=SC2034
92- DO_PERF_ANALYSIS=1
109+ else
110+
111+ for idx in $( seq 0 $(( PIPELINE_COUNT - 1 )) )
112+ do
113+ channel=$( func_pipeline_parse_value " $idx " channel)
114+ rate=$( func_pipeline_parse_value " $idx " rate)
115+ dev=$( func_pipeline_parse_value " $idx " dev)
116+ pcm=$( func_pipeline_parse_value " $idx " pcm)
117+ type=$( func_pipeline_parse_value " $idx " type)
118+
119+ # Currently, copier will convert bit depth to S32_LE despite what bit depth
120+ # is used in aplay, so make S32_LE as base bit depth for performance analysis.
121+ fmt=S32_LE
122+
123+ dlogi " Running (PCM: $pcm [$dev ]<$type >) in background"
124+ if [ " $type " == " playback" ]; then
125+ aplay_opts -D " $dev " -c " $channel " -r " $rate " -f " $fmt " -d " $duration " /dev/zero -q &
126+ aplay_num=$(( aplay_num+ 1 ))
127+ else
128+ arecord_opts -D " $dev " -c " $channel " -r " $rate " -f " $fmt " -d " $duration " /dev/null -q &
129+ arecord_num=$(( arecord_num+ 1 ))
130+ fi
131+ done
132+ fi
133+
134+ sleep 1 # waiting stable streaming of aplay/arecord
135+ dlogi " Number of aplay/arecord process started: $aplay_num , $arecord_num "
136+
137+ real_aplay_num=$( ps --no-headers -C aplay | wc -l)
138+ real_arecord_num=$( ps --no-headers -C arecord | wc -l)
139+ if [ " $real_aplay_num " != " $aplay_num " ] || [ " $real_arecord_num " != " $arecord_num " ];
140+ then
141+ dlogi " Number of aplay/arecord process running: $real_aplay_num , $real_arecord_num "
142+ die " aplay/arecord process exit unexpectedly"
143+ fi
144+
145+ dlogi " Waiting for aplay/arecord process to exit"
146+ sleep $(( duration + 2 ))
147+
148+ # Enable performance analysis
149+ # shellcheck disable=SC2034
150+ DO_PERF_ANALYSIS=1
151+ }
152+
153+ {
154+ main " $@ " ; exit " $? "
155+ }
0 commit comments