2020
2121set -e
2222
23+ PIPEWIRE_OUTPUTS=(" Speaker" " Headphones" " HDMI" )
24+ PIPEWIRE_INPUTS=(" Digital Microphone" " Headset Microphone" " SoundWire microphones" )
25+
2326# It is pointless to perf component in HDMI pipeline, so filter out HDMI pipelines
2427# shellcheck disable=SC2034
2528NO_HDMI_MODE=true
@@ -51,14 +54,14 @@ func_pipeline_export "$tplg" "type:any"
5154aplay_num=0
5255arecord_num=0
5356
54- if [ " $SOF_TEST_PIPEWIRE " == true ] ; then
55-
56- # aplay's for sinks
57- pw_outputs_list =(" Speaker " " Headphones " " HDMI " )
57+ # run aplay for all sink types given as a parameter and save the number of started aplay processes
58+ run_aplays ()
59+ {
60+ local sinks =(" $@ " )
5861
59- for sink_type in " ${pw_outputs_list [@]} "
62+ for sink_type in " ${sinks [@]} "
6063 do
61- sink_id=$( wpctl status | grep -A6 " Sinks " | grep -A3 -i " $sink_type " | tr -d ' * ' | awk ' {print $2} ' | tr -d ' . ' | head -n 1 )
64+ sink_id=$( get_id_of_pipewire_endpoint " $sink_type " )
6265 if [ -z " $sink_id " ]; then
6366 dlogi " No $sink_type found, skipping to the next one"
6467 continue
@@ -68,25 +71,37 @@ if [ "$SOF_TEST_PIPEWIRE" == true ]; then
6871 aplay_opts -Ddefault /dev/zero -q &
6972 aplay_num=$(( aplay_num+ 1 ))
7073 done
74+ }
7175
72- # arecord's for sources
73- pw_inputs_list=(" Digital Microphone" " Headset Microphone" " SoundWire microphones" )
76+ # run arecord for all source types given as a parameter and save the number of started arecord processes
77+ run_arecords ()
78+ {
79+ local sources=(" $@ " )
7480
75- for source_type in " ${pw_inputs_list [@]} "
81+ for source_type in " ${sources [@]} "
7682 do
77- source_id=$( wpctl status | grep -A6 " Sources " | grep -A3 -i " $source_type " | tr -d ' * ' | awk ' {print $2} ' | tr -d ' . ' | head -n 1 )
83+ source_id=$( get_id_of_pipewire_endpoint " $source_type " )
7884 if [ -z " $source_id " ]; then
7985 dlogi " No $source_type found, skipping to the next one"
80- continue # skip if that device type isn't available
86+ continue
8187 fi
8288 dlogi " Setting default source to $source_id : $source_type "
8389 wpctl set-default " $source_id "
8490 arecord_opts -Ddefault /dev/zero -q &
8591 arecord_num=$(( arecord_num+ 1 ))
8692 done
93+ }
94+
95+ if [ " $SOF_TEST_PIPEWIRE " == true ]; then
96+
97+ dlogi " Running aplays"
98+ run_aplays " ${PIPEWIRE_OUTPUTS[@]} "
99+ dlogi " Running arecords"
100+ run_arecords " ${PIPEWIRE_INPUTS[@]} "
101+ dlogi " Done"
87102
88- if [ $aplay_num == 0 ] && [ $arecord_num == 0 ]; then
89- skip_test " No sinks/sources to be tested found, exiting test"
103+ if [ " $aplay_num " == 0 ] && [ " $arecord_num " == 0 ]; then
104+ skip_test " No sinks/sources to be tested found, skipping test"
90105 fi
91106
92107else
0 commit comments