# Prune the audio graph down to what the RIG actually uses.
#
# WHY (2026-08-03): sound went glitchy-then-silent mid-rehearsal, J-5 before
# OPAL. Nothing had crashed — sclang, scsynth, the UMC sink and every link were
# healthy, and scsynth was using 6.7% CPU. The machine simply could not meet the
# audio deadline, and the UMC202HD (period_size 128) is the only device in the
# box with a deadline tight enough to notice. The internal speaker
# (period_size 1024) played fine throughout, which is what made it look like a
# Behringer fault. It was not: USB devnum stayed at 14, mixer at 127/127, links
# intact.
#
# `pw-top` named the actual cost. Xruns per node:
#
#   sof_sdw.HiFi__Headset__source   1,421,369     <- nothing uses it
#   sof_sdw.HiFi__HDMI1__sink         704,081     <- 2.8ms BUSY per cycle
#   UMC202HD Line sink                 32,338     <- the victim
#   alsa_input.hw_U192k_0              14,338     <- W/Q 1.24: waits > a full quantum
#   SuperCollider                       1,119
#   ardour                                422
#
# Two nodes NOBODY USES accounted for 2.1 million of them. HDMI1 appeared when
# PLN set up screen mirroring for the WYSIWYG show, and it burns 2.8ms of
# processing every cycle for an output with no client attached. Earlier the same
# device threw a `snd_pcm_start: File descriptor in bad state` retry storm.
#
# AND THE HEADSET MIC WAS IN THE RECORDING PATH. `pw-link` showed:
#     Headset__source:capture_FL -> ardour:Tidal 01/audio_in 1
# Ardour auto-connects physical inputs, so the laptop's microphone was summed
# into the input of the track that records d1, alongside SuperCollider:out_1.
# Disabling the source removes it structurally rather than relying on nobody
# ever re-arming that track.
#
# WHY THIS GOT BAD NOW: 52-no-suspend.conf disables suspension for ALL alsa
# nodes. That was written for a real reason — a woken device eats the attack of
# the first note — but applied graph-wide it holds six SOF sinks and a broken
# mic source permanently open and in the real-time graph. The fix that helped
# the UMC was amplifying everything else. That file is narrowed alongside this
# one.
#
# SCOPE / WHAT IS DELIBERATELY KEPT:
#   - Speaker and Headphones sinks stay ENABLED. They are the fallback that
#     proved the machine could still play audio at all during this incident,
#     and that diagnostic value is worth their (idle, suspendable) cost.
#   - The UMC's own capture stays enabled — the mic inputs are real I/O.
#   - Nothing here touches the UMC playback path.
#
# AUDIO OVER HDMI IS NOT IN THE SIGNAL CHAIN. The show goes UMC -> FOH; HDMI
# carries the mirrored SCREEN only. If a venue ever needs sound over HDMI,
# delete this file.
#
# To revert everything: delete this file and
#   systemctl --user restart wireplumber
# Then re-check TWO things that a wireplumber restart is known to break here
# (see memory reference_umc202hd_interface): the UMC sink volume resets to the
# device default (~87%), and Ardour's Master -> UMC link does NOT come back on
# its own.

monitor.alsa.rules = [
  {
    # The SOF headset-jack microphone. 1.4M xruns, no legitimate consumer, and
    # it had wired itself into the d1 stem recording.
    matches = [
      { node.name = "alsa_input.pci-0000_00_1f.3-platform-sof_sdw.HiFi__Headset__source" }
    ]
    actions = {
      update-props = {
        node.disabled = true
      }
    }
  }
  {
    # HDMI audio outputs. Screen mirroring brings these up; the rig never sends
    # audio through them. HDMI1 alone was 704k xruns and 2.8ms BUSY per cycle.
    matches = [
      { node.name = "alsa_output.pci-0000_00_1f.3-platform-sof_sdw.HiFi__HDMI1__sink" }
      { node.name = "alsa_output.pci-0000_00_1f.3-platform-sof_sdw.HiFi__HDMI2__sink" }
      { node.name = "alsa_output.pci-0000_00_1f.3-platform-sof_sdw.HiFi__HDMI3__sink" }
    ]
    actions = {
      update-props = {
        node.disabled = true
      }
    }
  }
]
