Repository navigation
linux-pulseaudio: Restart a stream whose own connection was dropped - #1057
Merged
Merged
Conversation
…nt (RED)
Fails, every run, in both lanes (10 of 10 each):
dropped_connection_restarts ("after the server dropped its stream's
connection: 'capture A' produced no audio within 3000 ms") and
repeated_connection_drops ("after its connection was dropped 1 times:
'capture A' produced no audio within 3000 ms").
Follow-up of obs-rust#532, which gives each capture stream a server connection
of its own. When the server drops only that connection, the stream
fails with its context, and pulse_stream_state_changed() takes the
failed context for the lost shared connection: it leaves the restart
to the reconnection, which never comes because the shared connection
is fine. The source stays silent for good, and nothing is logged.
test_pulse_stream_restart gains five cases:
- the server drops the connection of one source's stream (pw-cli
destroy on its client): audio must return within 3 s, and the other
source must not restart;
- the connection is dropped 5 times, then twice in a row before the
new stream delivers audio: audio returns each time, the source never
gives up, and no connection is leaked;
- controls, which pass today: a source destroyed while its restart
after a drop is pending leaks nothing; only the shared connection is
dropped, and the reconnection restarts each source once; pipewire-
pulse restarts, and each source is restarted once.
Refs obs-rust#1056.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since obs-rust#532 each capture stream has a server connection of its own besides the shared one. When the server dropped only a stream's connection, the stream failed with its context, and pulse_stream_state_changed() took the failed context for the lost shared connection: it left the restart to the reconnection, which never came because the shared connection was fine. The source stayed silent for good, with nothing in the log. Check the shared connection instead (pulse_connected()). A stream whose own connection is gone is restarted like any failed stream, through the retry, pause and limit of obs-rust#1031. A lost shared connection or a server restart is still left to the reconnection. If a stream's failure is seen before the shared connection's, its restart finds no server and does nothing, and the reconnection replaces the stream as before, so each source is still restarted once. test_pulse_stream_restart: 12 of 12, 10 of 10 runs in each lane. Fixes obs-rust#1056. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
enabled auto-merge
October 16, 2026 09:34
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.
Fixes #1056
Builds on #1031 (merged): the restart goes through its retry, pause and limit.
What and why
An Audio Input or Output Capture on PulseAudio or PipeWire now records again when the server drops its stream's own connection. Before, it went silent for good, with nothing in the log. This came in with our #532 (each capture stream gets a server connection of its own). It was found in the release check of #1031 and reproduced in 0.1.0-beta.20261014.
Cause
pulse_stream_state_changed()returns early when a failed stream's context is not ready: "With the whole connection lost, pulse_reconnected restarts it." Before linux-pulseaudio: Give each capture stream a connection of its own #532 the stream's context was the shared one, so that was right.In the release (0.1.0-beta.20261014 AppImage, private PipeWire + WirePlumber + pipewire-pulse,
pw-cli destroyon the PipeWire client of the source's stream):Fix (all in
plugins/linux-pulseaudio)pulse_connected()inpulse-wrapper.c: the shared connection is ready and not reconnecting.pulse_stream_state_changed()checks it instead of the stream's own context.pulse_stop_recording()frees the dead connection with the stream, as before.Not changed
pulse_connected()returning true), 3 of 3 runs logged that line for both sources, and the sources were still restarted exactly once. So the guard against a double restart is the existing stale-stream and no-server handling, and the new check just keeps the log clean.pw-cli destroyon the stream's client. On PulseAudio,pactl kill-clientshould reach the same state callback.RED → GREEN
test/cmocka: A dropped stream connection leaves its Pulse source silent (RED).test_pulse_stream_restartgains 5 cases.dropped_connection_restartsandrepeated_connection_dropsfail every run, 10/10 in each lane: "after the server dropped its stream's connection: 'capture A' produced no audio within 3000 ms" and "after its connection was dropped 1 times: ...". The 3 controls pass:source_destroyed_after_connection_drop,lost_shared_connection_restarts_onceandserver_restart_restarts_once. So do the 7 cases from linux-pulseaudio: Restart an input whose stream dies while connected #378 and linux-pulseaudio: Retry failed stream restarts with a pause and a limit #1031.test_pulse_stream_restartwithENABLE_RUST_LIBOBSOFF and ON, 10/10 runs alone in each lane, every case run against the private server (no skips), 34 s per run.test_pulse_reconnect14/14 (unchanged; it needs no server and runs in CI). Full ctest at-j8(private Xvfb, systemlibobs-openglmasked, TMPDIR unset): C lane 258/258, Rust lane 258/258. Skips:open_crashes_without_obs_core(intest_audio_ioandtest_video_io) in both lanes, as on master. One more per lane under load:test_startup_cycle_stress(C) andtest_startup_alloc_stable(Rust), whereobs_startup()failed. Both pass alone in both lanes, and neither is touched here. All PipeWire/Pulse tests ran. clang-format 22.1.3, gersemi 0.25.0 andci/test_registration.pyclean.test_pulse_stream_restartskips there (exit 77);test_pulse_reconnectruns.Checklist
master(after linux-pulseaudio: Retry failed stream restarts with a pause and a limit #1031 merges; stacked on it until then)-W..., ratchets): noneAI note: Claude Code (Claude Opus 5.5) wrote the code, the tests, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.
🤖 Generated with Claude Code