diff --git a/tools/smoke-test.sh b/tools/smoke-test.sh index bb56d83..feb6ca9 100755 --- a/tools/smoke-test.sh +++ b/tools/smoke-test.sh @@ -33,9 +33,7 @@ context.objects = [ media.class = "Audio/Sink" audio.position = [ FL FR ] object.linger = true } } ] -# The microphone is a loopback virtual source (like echo-cancel) rather than -# a null-audio-sink with a Source media class: WirePlumber's event dispatcher -# intermittently stalls on the latter, which blocks all linking. +# The microphone is a loopback virtual source, like echo-cancel creates. context.modules = [ { name = libpipewire-module-loopback args = { @@ -65,15 +63,31 @@ trap cleanup EXIT INT TERM pipewire >"$XDG_RUNTIME_DIR/pipewire.log" 2>&1 & PIDS="$PIDS $!" sleep 1 wireplumber >"$XDG_RUNTIME_DIR/wireplumber.log" 2>&1 & PIDS="$PIDS $!" -sleep 2 + +# wait_for : poll the probe (up to ~20 s) until it prints pattern. +wait_for() { + for _ in $(seq 1 40); do + "$PROBE" 2>/dev/null | grep -q -- "$1" && return 0 + sleep 0.5 + done + echo "timed out waiting for '$1'" + return 1 +} +# Let WirePlumber finish its startup (it has picked a default sink) before +# any stream appears: streams that show up while it is still initialising +# can wedge its event queue, after which nothing gets linked. +wait_for '\[default' LOGS="$XDG_RUNTIME_DIR" +# Two minutes of silence as a regular file: older pw-cat (PipeWire 1.4) +# silently exits when reading raw audio from /dev/zero. +head -c 23040000 /dev/zero > "$LOGS/silence.raw" pw-cat --playback --raw --rate 48000 --channels 2 --format s16 \ -P '{ application.name = "Test Player" media.name = "Smoke test tone" }' \ - /dev/zero >"$LOGS/play.log" 2>&1 & PIDS="$PIDS $!" + "$LOGS/silence.raw" >"$LOGS/play.log" 2>&1 & PIDS="$PIDS $!" pw-cat --record --raw --rate 48000 --channels 1 --format s16 \ -P '{ application.name = "Test Recorder" media.name = "Mic capture" }' \ /dev/null >"$LOGS/record.log" 2>&1 & PIDS="$PIDS $!" -sleep 2 +wait_for 'Test Player | .*-> ' || true fail=0 OUT="$LOGS/probe.out" @@ -92,7 +106,9 @@ step() { fi } step 'Test Player | 100%' -step 'Test Headphones | 50% (-18.06 dB)' volume test_headphones 50 +# Change the volume of the sink the test stream plays to: in CI (PipeWire +# 1.4) a volume set on an idle, suspended null sink was not applied. +step 'Test Speakers | 50% (-18.06 dB)' volume test_speakers 50 step 'Test Microphone | .*muted' mute test_mic 1 step 'Test Headphones | .*\[default\]' default test_headphones STREAM=$("$PROBE" | awk -F: '/Test Player/ {gsub(/ /,"",$1); print $1; exit}')