Repository navigation
fix(recording): stop Linux system audio from silently recording the microphone - #4495
Merged
richiemcilroy merged 15 commits intoNov 27, 2026
Merged
richiemcilroy merged 15 commits into
richiemcilroy merged 15 commits into
Conversation
Audio-only system audio now ends its own track after the reconnect grace, and the take saves with the microphone still in it. A monitor that returns during the grace keeps the take running. Screen recordings are unchanged. Co-authored-by: Kyzer <kyzer1023@users.noreply.github.com>
PipeWire moves a capture onto the default source when its monitor disappears, and the stream stays open. Treat a source that is not a sink .monitor as a system-audio loss: drop those samples, move the stream back onto the current output monitor when one exists, and otherwise end the track after the reconnect grace. A stream that errors still follows the existing PulseAudio path. Co-authored-by: Kyzer <kyzer1023@users.noreply.github.com>
Contributor
Author
Contributor
|
@kyzer1023 is attempting to deploy a commit to the Cap Software Inc Team on Vercel. A member of the Team first needs to authorize it. |
kyzer1023
added a commit
to kyzer1023/Cap
that referenced
this pull request
Nov 23, 2026
…pen ID 8 (CapSoftware#4495), run ID 12 on laptop
kyzer1023
added a commit
to kyzer1023/Cap
that referenced
this pull request
Nov 23, 2026
Windows and macOS builds no longer reference the Linux capture gate. System-audio samples stay staged until a later pactl read still sees a sink monitor; a microphone reroute drops every unconfirmed chunk. A closed pactl subscribe waits out its backoff instead of spinning, and the null-sink reload test checks the post-reload tone. Co-authored-by: Kyzer <kyzer1023@users.noreply.github.com>
Contributor
Author
kyzer1023
added a commit
to kyzer1023/Cap
that referenced
this pull request
Nov 23, 2026
Route checks start when the system-audio stream starts, so the startup observer can receive a sample before Lock. Delayed chunks captured on a monitor stay queued for the next check, while audio from before a microphone reroute is still dropped. Stop waits for the held samples to reach the muxer before the feed is killed. The Linux-only capture epoch, route grace, and stop flag no longer fail Windows or macOS clippy.
Contributor
Author
kyzer1023
added a commit
to kyzer1023/Cap
that referenced
this pull request
Nov 23, 2026
kyzer1023
added a commit
to kyzer1023/Cap
that referenced
this pull request
Nov 24, 2026
Keep the system-audio route watcher, staging cutoff, and stop flush alongside the microphone delivery clock and enqueue failure log.
A monitor device cpal lists by name never builds a PulseInputRoute, so its staged samples were never released and system-audio startup timed out. Snapshot that source output and start the route watcher before the stream is reported ready.
kyzer1023
added a commit
to kyzer1023/Cap
that referenced
this pull request
Nov 25, 2026
…system-audio-loss # Conflicts: # crates/recording/src/feeds/microphone.rs # crates/recording/src/sources/microphone.rs
Member
|
hey @greptileai, please re-review the PR |
Member
|
hey @greptileai, please re-review the PR |
Member
|
hey @greptileai, please re-review the PR |
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.
Why
On Linux with PipeWire (
pipewire-pulse), unloading or losing the default output sink during an Audio Only recording causes PipeWire to silently reroute the system-audio capture stream onto the default input source (the hardware microphone) while leaving the stream open without erroring. That silently records the user's microphone intosystem_audio.m4a, or hangs the system-audio track when no output.monitorexists.What changed
.monitorsource (crates/recording/src/sources/screen_capture/linux.rs,crates/recording/src/feeds/microphone.rs,crates/recording/src/sources/microphone.rs), dropping samples from non-monitor sources instead of writing microphone audio to the system track..monitorexists (or returns within the 3 s reconnect grace window), move the capture stream back onto the active output.monitorand keep the recording running..monitorreturns within the 3 s grace window during an Audio Only take, end the system-audio track cleanly and save the recording with the microphone track intact (crates/recording/src/studio_recording.rs,apps/desktop-gpui/src/session.rs). Screen recordings and PulseAudio error-stream paths are unchanged.crates/recording/src/sources/screen_capture/linux/audio_only_null_sink_tests.rsandsystem_audio_channel_tests.rs.Verification
Verified on Linux Mint 22.3 (PipeWire 1.0.5 /
pipewire-pulse, XFCE/X11) with Audio Only + system audio On + hardware micdefaultOn and a 440 Hz tone routed into a temporarycap_id8_nullsink:.monitorexists: PipeWire briefly parked system-audio stream#1561on the hardware mic (1174); within ~1 s Cap moved#1561ontoalsa_output.pci-0000_00_1f.3.analog-stereo.monitor(1173). Recording finishedComplete(system_audio.m4a: 33.893 s, 48 kHz 2 ch AAC, 440 Hz throughout;audio-input.m4a: 33.899 s room noise; last-5 s system-vs-mic correlation0.0084).#7740recovered onto the recreatedcap_id8_null.monitor(10805). Recording finishedComplete(system_audio.m4a: 26.623 s;audio-input.m4a: 26.645 s; post-recovery system-vs-mic correlation-0.0005)..monitor(module-always-sinkunloaded + card switched toinput:analog-stereo): PipeWire moved stream#12473onto the hardware mic -> Cap loggedSystem audio capture is not on an output monitor source_output=12473, waited the grace window (3.08 s), loggedAudio-only system audio ended before Stop track=SystemAudioand stopped/saved the recording cleanly (status: "Complete",audioOnly: true).system_audio.m4aended cleanly at15.730 s(440 Hz only, no mic bleed) whileaudio-input.m4akept18.588 sof mic audio.

Confidence Score: 5/5
The latest change appears safe to merge; no new blocking issue was found.Summary
This PR protects Linux system audio from microphone reroutes and saves Audio Only recordings when the output monitor stays unavailable.
Reviews (8) · Last reviewed commit: "fix: write the microphone finish_capture..." · Reviewed by Greptile