@@ -83,6 +83,10 @@ minvalue() { printf '%d' $(( "$1" < "$2" ? "$1" : "$2" )); }
8383#
8484start_test ()
8585{
86+ if [ " $TEST_WITH_PIPEWIRE " == true ]; then
87+ func_lib_enable_pipewire
88+ fi
89+
8690 if is_subtest; then
8791 return 0
8892 fi
@@ -571,6 +575,44 @@ func_lib_check_sudo()
571575 }
572576}
573577
578+ func_lib_enable_pipewire ()
579+ {
580+ dlogi " Starting Pipewire..."
581+ systemctl --user daemon-reexec
582+ systemctl --user daemon-reload
583+ systemctl --user unmask pipewire{,-pulse}.{socket,service}
584+ systemctl --user start pipewire{,-pulse}.{socket,service}
585+ systemctl --user unmask wireplumber.service
586+ systemctl --user start wireplumber.service
587+
588+ # Wait for pipewire to start
589+ sleep 5s
590+
591+ if [ " $( ps -C pipewire --no-header) " ]; then
592+ dlogi " Pipewire started"
593+ else
594+ die " Failed to start pipewire"
595+ fi
596+ }
597+
598+ func_lib_disable_pipewire ()
599+ {
600+ dlogi " Stopping Pipewire..."
601+
602+ # Kill any left pipewire processes
603+ # pkill -9 arecord
604+ # pkill -9 aplay
605+ sleep 2s
606+
607+ systemctl --user stop pipewire{,-pulse}.{socket,service}
608+ systemctl --user mask pipewire{,-pulse}.{socket,service}
609+ systemctl --user stop wireplumber.service
610+ systemctl --user mask wireplumber.service
611+
612+ # Wait for pipewire to stop
613+ sleep 2s
614+ }
615+
574616systemctl_show_pulseaudio ()
575617{
576618 printf ' \n'
@@ -908,9 +950,15 @@ aplay_opts()
908950 # shellcheck disable=SC2086
909951 tinyplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS -D " $card_nr " -d " $dev_nr " -i wav noise.wav
910952 elif [[ " $SOF_ALSA_TOOL " = " alsa" ]]; then
911- dlogc " aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $* "
912- # shellcheck disable=SC2086
913- aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS " $@ "
953+ if [[ " $TEST_WITH_PIPEWIRE " == true ]]; then
954+ dlogc " timeout -k 60 30 aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $* " # option -d doesn't work with pipewire so we need timeout
955+ # shellcheck disable=SC2086
956+ timeout -k 60 30 aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS " $@ "
957+ else
958+ dlogc " aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $* "
959+ # shellcheck disable=SC2086
960+ aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS " $@ "
961+ fi
914962 else
915963 die " Unknown ALSA tool: ${SOF_ALSA_TOOL} "
916964 fi
@@ -927,9 +975,15 @@ arecord_opts()
927975 # shellcheck disable=SC2086
928976 tinycap $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $file " -D " $card_nr " -d " $dev_nr " -c " $channel " -t " $duration " -r " $rate " -b " $format "
929977 elif [[ " $SOF_ALSA_TOOL " = " alsa" ]]; then
930- dlogc " arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $* "
931- # shellcheck disable=SC2086
932- arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $@ "
978+ if [[ " $TEST_WITH_PIPEWIRE " == true ]]; then
979+ dlogc " timeout -k 60 30 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $* " # option -d doesn't work with pipewire so we need timeout
980+ # shellcheck disable=SC2086
981+ timeout -k 60 30 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $@ "
982+ else
983+ dlogc " arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $* "
984+ # shellcheck disable=SC2086
985+ arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $@ "
986+ fi
933987 else
934988 die " Unknown ALSA tool: ${SOF_ALSA_TOOL} "
935989 fi
0 commit comments