@@ -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,55 @@ func_lib_check_sudo()
571575 }
572576}
573577
578+ pipewire_unmask_manually ()
579+ {
580+ services=(" pipewire.service" " pipewire-pulse.service" " wireplumber.service" " pipewire.socket" " pipewire-pulse.socket" )
581+
582+ for service in " ${services[@]} " ; do
583+ pw_service_path=$( systemctl --user show -p FragmentPath " $service " )
584+ pw_service_path=${pw_service_path/ " FragmentPath=" / }
585+ pw_service_link=$( ls -l " $pw_service_path " )
586+ if [[ " $pw_service_link " == * " /dev/null" ]]; then # Delete link if it points to /dev/null
587+ dlogi " Found ->/dev/null link: $pw_service_path , removing it"
588+ sudo rm " $pw_service_path "
589+ fi
590+ done
591+ }
592+
593+ start_pipewire_services ()
594+ {
595+ systemctl --user daemon-reexec
596+ systemctl --user daemon-reload
597+ systemctl --user unmask pipewire{,-pulse}.{socket,service}
598+ systemctl --user start pipewire{,-pulse}.{socket,service}
599+ systemctl --user unmask wireplumber.service
600+ systemctl --user start wireplumber.service
601+ }
602+
603+ func_lib_enable_pipewire ()
604+ {
605+ dlogi " Starting Pipewire..."
606+ # Sometimes unmasking does not work as expected, and we need to manually delete /dev/null links and try again
607+ start_pipewire_services || true
608+ pipewire_unmask_manually
609+ start_pipewire_services
610+
611+ # Wait for pipewire to start
612+ sleep 5s
613+ }
614+
615+ func_lib_disable_pipewire ()
616+ {
617+ dlogi " Stopping Pipewire..."
618+ systemctl --user stop pipewire{,-pulse}.{socket,service}
619+ systemctl --user mask pipewire{,-pulse}.{socket,service}
620+ systemctl --user stop wireplumber.service
621+ systemctl --user mask wireplumber.service
622+
623+ # Wait for pipewire to stop
624+ sleep 2s
625+ }
626+
574627systemctl_show_pulseaudio ()
575628{
576629 printf ' \n'
@@ -908,9 +961,15 @@ aplay_opts()
908961 # shellcheck disable=SC2086
909962 tinyplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS -D " $card_nr " -d " $dev_nr " -i wav noise.wav
910963 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 " $@ "
964+ if [[ " $TEST_WITH_PIPEWIRE " == true ]]; then
965+ dlogc " timeout -k 60 30 aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $* " # option -d doesn't work with pipewire so we need timeout
966+ # shellcheck disable=SC2086
967+ timeout -k 60 30 aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS " $@ "
968+ else
969+ dlogc " aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS $* "
970+ # shellcheck disable=SC2086
971+ aplay $SOF_ALSA_OPTS $SOF_APLAY_OPTS " $@ "
972+ fi
914973 else
915974 die " Unknown ALSA tool: ${SOF_ALSA_TOOL} "
916975 fi
@@ -927,9 +986,15 @@ arecord_opts()
927986 # shellcheck disable=SC2086
928987 tinycap $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $file " -D " $card_nr " -d " $dev_nr " -c " $channel " -t " $duration " -r " $rate " -b " $format "
929988 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 " $@ "
989+ if [[ " $TEST_WITH_PIPEWIRE " == true ]]; then
990+ dlogc " timeout -k 60 30 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $* " # option -d doesn't work with pipewire so we need timeout
991+ # shellcheck disable=SC2086
992+ timeout -k 60 30 arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $@ "
993+ else
994+ dlogc " arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS $* "
995+ # shellcheck disable=SC2086
996+ arecord $SOF_ALSA_OPTS $SOF_ARECORD_OPTS " $@ "
997+ fi
933998 else
934999 die " Unknown ALSA tool: ${SOF_ALSA_TOOL} "
9351000 fi
0 commit comments