Skip to content

Add a low-latency audio toggle - #13838

Closed
manuaudio wants to merge 7 commits into
omacom:quattrofrom
manuaudio:feat/low-latency-audio-toggle
Closed

manuaudio wants to merge 7 commits into
omacom:quattrofrom
manuaudio:feat/low-latency-audio-toggle

Conversation

@manuaudio

@manuaudio manuaudio commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

This adds a session-scoped low-latency audio switch for recording and software instruments.

PipeWire normally chooses a power-friendly graph quantum. On my stock setup I measured 1024–2048 samples, or about 21–43 ms at 48 kHz. The new omarchy toggle low-latency-audio [toggle|on|off|--status] command uses pw-metadata to force 256 samples, about 5 ms, and clears the override back to 0 when switched off. It does not restart audio, and PipeWire returns to its automatic choice at the next session.

The command refuses to replace a different forced quantum unless on is requested explicitly. It also fails without notifying when the current setting cannot be read or a write is rejected. When enabling the switch, it checks this user's PipeWire data loop for realtime scheduling and warns if the small buffer is likely to crackle under load.

The Toggle menu presents separate on/off actions that follow the current setting. The English menu and notification catalogs cover the new strings, and the manual documents the runtime scope and realtime requirement.

Regression proof:

  • test/shell.d/low-latency-audio-test.sh: 9 focused assertions pass, covering state changes, explicit on/off, read and write failures, foreign forced values, argument validation, realtime detection, and current menu wiring.
  • I18N_STRUCTURAL=1 test/shell.d/i18n-test.sh: 401 passed, 0 failed.
  • test/shell.d/menu-test.sh: 200 passed, 0 failed.
  • Bash syntax, ShellCheck, the i18n extraction scan, and git diff --check pass.
  • A fresh Codex review found no blocking issue.

I previously verified the command against live PipeWire 1.6.8 with a stream playing: the graph moved from 2048 to 256 samples and returned to 2048 when disabled. I did not repeat that live check after merging current quattro; the PipeWire code path did not change.

Recording or playing software instruments wants a small audio buffer, and PipeWire's default quantum is sized for power, not latency. omarchy toggle low-latency-audio forces a 256-sample quantum (about 5 ms at 48 kHz) and clears it again, the equivalent of the buffer size in macOS's Audio MIDI Setup. It is a runtime setting, so nothing restarts and playback carries on, and the next session starts back on the default. When rtkit is missing, PipeWire cannot take realtime priority and a buffer this small can crackle, so the notification says so. The Toggle menu shows it with its state checked, and the toggles manual page documents it.

Refs omacom#13832

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@manuaudio
manuaudio marked this pull request as ready for review October 1, 2026 19:28
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues remain.

Summary

Adds a runtime low-latency audio switch that sets PipeWire's buffer to 256 samples and clears the override when disabled.

  • Users can switch PipeWire to a smaller audio buffer for the current session.

Reviews (6) · Last reviewed commit: "Merge current quattro into low-latency a..." · Reviewed by Greptile

Comment thread bin/omarchy-toggle-low-latency-audio Resolved
Comment thread bin/omarchy-toggle-low-latency-audio Resolved
Comment thread bin/omarchy-toggle-low-latency-audio Resolved
…me priority directly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread bin/omarchy-toggle-low-latency-audio Resolved
Comment thread bin/omarchy-toggle-low-latency-audio Resolved
Comment thread bin/omarchy-toggle-low-latency-audio Resolved
manuaudio and others added 2 commits October 1, 2026 12:38
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the enhancement New feature or request label Oct 1, 2026
Comment thread test/shell.d/low-latency-audio-test.sh Outdated
Comment on lines +68 to +71
if PIPEWIRE_DOWN=1 toggle on 2>/dev/null; then
fail "a failed PipeWire write is reported as a failure"
fi
[[ ! -s $tmp/notifications ]] || fail "a failed PipeWire write sends no notification" "$(cat "$tmp/notifications")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed writes go untested

PIPEWIRE_DOWN=1 makes the stub fail the initial read, so this case never reaches a write. It would still pass if set_quantum stopped checking write failures, leaving that behavior unprotected.

Add a separate write-only failure flag. Let the initial read succeed, then check that the command fails without changing the setting or sending a notification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile was right: PIPEWIRE_DOWN=1 failed the initial read, so the alleged write-failure case never reached set_quantum. Commit 2ff70c64 adds a separate write-only failure flag, lets the read succeed, and verifies that on exits non-zero without changing the quantum or sending a notification. The focused test passes, along with Bash syntax, shellcheck, and git diff --check; a fresh Codex review found no issue.

@manuaudio

Copy link
Copy Markdown
Contributor Author

Closing this to keep my open PRs to a handful. Thanks for looking, and I'm happy to reopen it if it's still useful.

@manuaudio manuaudio closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants