coverage_audio.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. # The audio and LED paths of a coverage build: sound scenes against a private PulseAudio server (never the desktop's;
  3. # tools/wecompare/wine/audio_sink.sh), first with a plain null sink, then with a default sink that calls itself a headset
  4. # so the headphone detector and HRTF switch on, a web wallpaper with audio for the per process volume, and the LED
  5. # output against the fake OpenRGB server of tools/check_leds.sh.
  6. # Usage: tools/analysis/coverage_audio.sh <engine binary> [assets dir] [workshop content dir]
  7. set -uo pipefail
  8. HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
  9. BINARY=${1:?engine binary}
  10. ASSETS=${2:-/workspace/SteamLibrary/steamapps/common/wallpaper_engine/assets}
  11. CONTENT=${3:-/workspace/SteamLibrary/steamapps/workshop/content/431960}
  12. SINK="$HERE/wecompare/wine/audio_sink.sh"
  13. work=$(mktemp -d /tmp/lwe-coverage-audio.XXXXXX)
  14. trap '"$SINK" stop > /dev/null 2>&1; rm -rf "$work"' EXIT
  15. "$SINK" start || { echo "SKIP: no private PulseAudio"; exit 0; }
  16. eval "$("$SINK" env)"
  17. export HEADLESS_RENDER_PULSE_SERVER=$PULSE_SERVER
  18. private_pactl () { PULSE_SERVER=$HEADLESS_RENDER_PULSE_SERVER pactl "$@"; }
  19. # headless_render.sh refuses a PULSE_SERVER in its own environment, it is handed the private one explicitly
  20. unset PULSE_SERVER
  21. scenes=${SOUND_SCENES:-"3509578940 3737268876 3354366708 3287715210"}
  22. render () {
  23. local label=$1
  24. shift
  25. if HEADLESS_RENDER_DELAY=250 HEADLESS_RENDER_TIMEOUT=120 HEADLESS_RENDER_SIZE=800x450 \
  26. "$HERE/headless_render.sh" "$BINARY" "$work/shot.png" --assets-dir "$ASSETS" "$@" > "$work/run.log" 2>&1; then
  27. echo "ok $label"
  28. else
  29. echo "FAIL $label"
  30. tail -3 "$work/run.log"
  31. fi
  32. rm -f "$work/shot.png"
  33. }
  34. for id in $scenes; do
  35. [ -d "$CONTENT/$id" ] && render "scene $id on a speaker sink" --volume 64 "$CONTENT/$id"
  36. done
  37. private_pactl load-module module-null-sink sink_name=lwe_headset rate=48000 channels=2 \
  38. sink_properties=device.form_factor=headset > /dev/null && private_pactl set-default-sink lwe_headset
  39. for id in $scenes; do
  40. [ -d "$CONTENT/$id" ] && render "scene $id on a headset sink" --volume 64 --hrtf auto "$CONTENT/$id"
  41. done
  42. for id in $scenes; do
  43. [ -d "$CONTENT/$id" ] && render "scene $id with hrtf off" --volume 64 --hrtf off "$CONTENT/$id" && break
  44. done
  45. for id in 1078208425 3026605859; do
  46. [ -d "$CONTENT/$id" ] && HEADLESS_RENDER_WEB=1 render "web $id with sound" --volume 40 --ambient-volume 30 "$CONTENT/$id"
  47. done
  48. "$HERE/check_leds.sh" "$BINARY" "$CONTENT/3509578940" "$work/leds" --assets-dir "$ASSETS" > "$work/leds.log" 2>&1 \
  49. && echo "ok leds" || { echo "FAIL leds"; tail -3 "$work/leds.log"; }