Wake the Asahi mic mapper on PipeWire events instead of polling every 2 s - #403
Open
skuthus wants to merge 1 commit into
Open
Wake the Asahi mic mapper on PipeWire events instead of polling every 2 s#403skuthus wants to merge 1 commit into
skuthus wants to merge 1 commit into
Conversation
--watch re-ran pw-dump and several pactl queries every 2 s, which kept pipewire, pipewire-pulse and wireplumber awake around the clock: 14.2% of a core on an idle M1 Max, 0.3% after. supervise() now sleeps on pactl subscribe and repairs when a sink, source, card or module appears or vanishes, a card or module changes, or the server does. Stream, client and sink/source change events are ignored; bursts settle for 0.5 s with a 5 s cap; a 10-minute backstop keeps eventual consistency. A lost subscription repairs once and resubscribes after 2 s. SIGTERM unwinds through supervise so the subscriber exits with the service. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WHvo2RfghRcv7UoqFntuM9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
omarchy-asahi-mic.service --watchre-ranpw-dumpplus severalpactlqueries every 2 seconds, forever, on every Apple Silicon machine. Measured on a MacBook Pro 14" (M1 Max), Omarchy 4.0.3-1, nothing playing:The stack never idled because the poll kept it awake.
What changed —
bin/omarchy-audio-asahi-mic-map(+110 / −13)supervise()sleeps onpactl subscribeand repairs only when something that can break the mapping happens: a sink, source, card or module appears or vanishes, a card or module changes, or the server changes (pipewire-pulse restart, default device switch).changeevents: every stream start and stop emits those, and the mapping depends only on node existence, links and defaults.omarchy-restart-audio --save-statestill saves immediately.superviseso the subscriber child exits with the service.Unit file, migration and the
--save-statepath are unchanged.supervise(operation, wait=None)keeps working for existing callers; the test injectswait.Verified on hardware
pactl load-module module-null-sink …→ repair ran inside the settle window.pactl unload-module <omarchy_asahi_mic>→ sink rebuilt after ~500 ms.paplaya 0.5 s clip → zero repairs triggered.kill -TERMthe watcher → nopactl subscribeleft behind.Tests
test/shell.d/asahi-mic-map-test.shpasses. New coverage: wake on device event, wake on server change, no wake on stream events, settle cap, lost subscription, missing subscriber.To review in 2 minutes
Read
Subscription.wait()(25 lines). Everything else is plumbing.🤖 Generated with Claude Code
https://claude.ai/code/session_01WHvo2RfghRcv7UoqFntuM9