Skip to content

Map the DSP microphone's MONO port and recover it after an update - #54

Merged
maralcbr merged 6 commits into
mainfrom
fix/mic-mono-port
Oct 24, 2026
Merged

maralcbr merged 6 commits into
mainfrom
fix/mic-mono-port

Conversation

@maralcbr

@maralcbr maralcbr commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Summary

Two follow-ups to omacom/omarchy-pkgs#1527 (the missing triforce-lv2 that left the M2 Max's built-in mic silent), in omarchy-audio-asahi-mic-map. omarchy-mac 0.2.2 (rebased on 0.2.0; #56 takes 0.2.1).

  • MONO port. Upstream asahi-audio ab1b469 renames the DSP mic's mono output from AUX0 to MONO, and the mapper hardcoded capture_AUX0.
    • It now takes the DSP's single mono port, capture_AUX0 or capture_MONO.
    • It maps onto FL/FR, or onto a single input_MONO when PipeWire negotiates the capture side down to mono.
    • Any other port shape (duplicates, mixed) is refused and rolled back.
  • Recovery after an update. Installing a missing graph plugin brings no audio event, since WirePlumber builds the mic filter only when the array's node appears, so the mic stayed missing until a restart.
    • The watcher's two-second poll now also checks /usr/lib/lv2, /usr/share/asahi-audio and wireplumber.conf.d (and their subdirectories).
    • When a finished pacman transaction has changed them, the DSP mic is missing, and an enabled Apple array card is present (AppleJ*HPAI/AOP), it asks omarchy-audio-watchdog to restart WirePlumber once, regardless of the repair interval.
    • The pending repair, its signature and its deferred retry time live in an atomic record in the runtime dir, so they survive the mapper reloading its own upgraded file.
    • While that repair is pending it owns recovery: the outage repair and notice wait, it never runs during a pacman transaction, and a deferred one retries after 30 s and not sooner.
  • README, manual and comments updated.

Review

GPT-6 Astra, four rounds. Fixed along the way:

  • negotiated MONO capture
  • duplicate-port ambiguity
  • pending state and retry time lost across a reload
  • outage and update repairs overlapping
  • the pacman gate on retries
  • directory read errors
  • non-deterministic tests and host state in tests
  • version bump

Final verdict: CORRECT.

Tests

omarchy-mac/test/mic-test.sh and mic-reload-test.sh pass, and CI ran both:

  • every AUX0/MONO × stereo/negotiated shape, plus the rejected ambiguous ones
  • Audio.array() against card fixtures
  • Installed gating, reload and persistence
  • the deferred, busy and reload sequences under mocked time
  • unreadable directories

Not yet verified

Live on the M2 Max (remove triforce-lv2, reinstall it with the watcher running). The Mac is off the network right now.

Depends on #56 for the watchdog to accept automatic restarts on Quickshell 0.3.2; without it the update repair is declined like every other automatic restart.

@maralcbr
maralcbr requested a review from scottjones as a code owner October 23, 2026 14:27
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no actionable issues found in the latest changes.

Summary

The PR supports AUX0 and MONO microphone ports and adds recovery after audio package updates.

  • The mapper accepts Asahi's renamed mono port and negotiated capture shapes.
  • The microphone mapper retries audio recovery after package updates.

Reviews (7) · Last reviewed commit: "Count only array cards asahi-audio build..." · Reviewed by Greptile

@maralcbr

Copy link
Copy Markdown
Member Author

Hardware run: M2 Max (Mac14,6, J416), 2026-10-24 Brisbane

This PR's mapper was installed over 0.1.4 on a running session (aurora-audio 4.1.aurora3-2, WirePlumber 0.5.18, PipeWire 1.6.9).

  • Reload: the running watcher reloaded into the new file ("Running the updated microphone mapper") and wrote its runtime record (44 entries, nothing pending).
  • Break: pacman -Rdd triforce-lv2. The change was seen 1 s after pacman finished, and the watchdog restarted WirePlumber ("audio files changed while the Asahi DSP microphone was missing"). The DSP mic stayed missing, as expected without the plugin.
  • Recover: pacman -S triforce-lv2 at 09:57:45.
    • 09:57:46: detected and requested. The watchdog deferred: "audio was restarted moments ago".
    • 09:58:16: retried exactly 30 s later, and WirePlumber was restarted.
    • 09:58:17.56: effect_output.j416-mic was back, and omarchy_asahi_mic was the default 20 ms later.
    • A 3 s capture had 98304/98304 nonzero samples, RMS 0.027. No "microphone unavailable" notice appeared.

Caveat: the run needed a lab-only patch to the installed omarchy-audio-watchdog, since reverted. Under LC_ALL=C, Quickshell 0.3.2 prints its locale warning on stdout, so shell_instances() can't parse quickshell list -j and every automatic restart is declined with "the shell state is unknown". record() runs before stop_shell(), so those refusals still use up the 3-per-hour WirePlumber budget. In the first attempt, three refusals right after login exhausted it and the real repair was refused with EXHAUSTED. That's a separate pre-existing watchdog bug, not this PR's.

asahi-audio ab1b469 names the mono DSP output MONO instead of AUX0. The
mapper only looked for capture_AUX0, so it would stop mapping as soon as
Aurora's asahi-audio picks that change up. It now takes the one mono port
the DSP offers, AUX0 or MONO, and refuses a DSP that offers both.

When an update installs what the DSP graph lacked (aurora-audio without
triforce-lv2 left every array Mac but J700 without its DSP microphone,
omacom/omarchy-pkgs#1527), no audio event follows: WirePlumber builds the
filter only when the array's node appears, so the microphone stayed
missing until a restart. The watcher now also polls the LV2, asahi-audio
and WirePlumber configuration directories on its two-second schedule.
Once a pacman transaction that changed them has finished, and the DSP
microphone is missing while an Apple array card is present and enabled,
it asks omarchy-audio-watchdog to restart WirePlumber once, regardless of
the repair interval. The last signature is kept in the runtime directory,
so a watcher that reloads its own upgraded file in the same transaction
still sees the change. Macs without an array, or with the card off, are
left alone.
…s reloads

- The mapping's capture side can be one input_MONO port once PipeWire
  negotiates against a MONO DSP port; map onto that or onto FL/FR, and
  refuse a graph offering both shapes. dsp_port() counts every AUX0 and
  MONO candidate together, so duplicates are refused too.
- The update record in the runtime directory now holds the signature and
  whether the repair is pending, written atomically, so a watcher that
  execs its upgraded file before the repair ran keeps it.
- While that repair is pending it owns recovery: the outage repair and
  notice wait, a deferred restart is retried after 30 s and not sooner,
  and a successful one counts as the outage repair.
- An unreadable directory leaves the previous signature in place instead
  of raising through the watcher's wait.
- Tests: negotiated MONO, ambiguous graphs, real Audio.array() against
  card fixtures, the reload sequence, a deferred repair with an overdue
  outage under mocked time, an unreadable directory, explicit timestamps,
  and the host's model and sound cards kept out.
- Manual wording says the restart is attempted; omarchy-mac 0.1.5.
…oads

- A pending repair now checks for a running pacman transaction itself and
  looks again in 5 s, so a repair deferred during one update never
  restarts WirePlumber in the middle of the next.
- The runtime record keeps the deferred retry time, and a reloaded
  watcher restores it and its wake, so an early event after a reload does
  not retry before the 30 s are up.
- capture_inputs() counts every FL, FR and MONO candidate: exactly one FL
  and one FR, or exactly one MONO, and nothing else, is mapped.
- The reload test watches no host audio directories; Installed reads
  AUDIO_FILES when constructed rather than at definition.
- README, manual and the linking comment describe negotiated MONO and the
  attempted restart.
A directory change noticed while a deferred repair was pending cleared its
retry time, so the next event asked the watchdog again before 30 s.
The first run of this mapper comes after the update that installed it,
and that update may also have brought the plugin the DSP graph lacked
(aurora-audio 4.1.aurora3-2 pulls in triforce-lv2). With no record the
watcher took the updated tree as its starting point and never saw the
change, and with no mapping yet the outage repair never ran either, so
the microphone stayed missing until a reboot.

A watcher with no record (or a damaged one) now starts with a pending
repair due 30 s later. A DSP microphone present by then ends it without a
restart, which is the usual case at login; a DSP still missing on a Mac
with an enabled array gets the one WirePlumber restart.
Audio.array() matched any AppleJ*HPAI or AOP card, so a card without a
microphone graph in asahi-audio's rules could still get the update and
first-look restarts. It now also requires that a rule under
/usr/share/wireplumber/wireplumber.conf.d names the card ("hw:<id>,"),
as aurora-audio's 99-asahi.conf does for AppleJ416HPAI and AppleJ700AOP.

The first look runs once per fresh runtime directory, so a session whose
microphone is still missing 30 s after it starts gets one restart; the
manual says so, and a test covers the second session start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant