Repository navigation
linux-pulseaudio: Retry failed stream restarts with a pause and a limit - #1031
Merged
Merged
Conversation
zackees
enabled auto-merge
October 16, 2026 07:40
auto-merge was automatically disabled
October 16, 2026 08:20
Pull request was closed
zackees
force-pushed
the
fix/pulse-restart-backoff-2
branch
from
October 16, 2026 08:20
3146a80 to
998df8a
Compare
zackees
enabled auto-merge
October 16, 2026 08:20
This was referenced Oct 16, 2026
zackees
added a commit
that referenced
this pull request
Oct 16, 2026
…ng Qt (#1046) The Fast Gate's "Build Touched Linux Targets" step configured the tree without Qt, but plugins/frontend-tools is a core module that calls find_package(Qt6 REQUIRED Widgets). So every PR that touched a plugin failed at configure (#1031, #1037, #1016). Install the distro Qt packages for that step so configure passes. Only the touched non-Qt targets are built, and the Qt build and tests stay in the path-scoped Qt lane.
auto-merge was automatically disabled
October 16, 2026 08:40
Pull request was closed
zackees
added a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 16, 2026
…ix) (obs-rust#1045) * test: Qt plugins opt out before requiring Qt (RED) The Fast Gate (obs-rust#1013) configures the touched Linux targets with no Qt. frontend-tools calls find_package(Qt6 REQUIRED) unconditionally, so that configure fails on every PR that builds C (obs-rust#1016, obs-rust#1031, obs-rust#1037). * frontend-tools: Skip the plugin when the frontend is off (GREEN) frontend-tools is frontend UI and requires Qt. Return before find_package(Qt6) when ENABLE_FRONTEND is OFF, as the AJA, DeckLink, VST and websocket plugins do with their own options, so the Fast Gate's Qt-free configure succeeds.
…ed (RED)
Fails, every run, in both lanes: failed_restart_is_retried ("produced
no audio within 3000 ms") and failing_stream_is_paced_then_given_up
("restarted 52 times in 1 s, 18 ms apart at the least, expected
100 ms"; seen once under load, when the restarts came further apart:
"still restarting the failing stream after 16 s (227 attempts)").
Follow-up of obs-rust#377/obs-rust#378. When a source's own stream fails while the
server stays up, the input restarts it once. If that restart fails
synchronously (the stream cannot be created or connected) while the
device is there and the server is connected, nothing retries it: only
a device appearing would. If the restarted stream keeps failing, the
input restarts it at once every time, with no pause and no limit;
since obs-rust#532 every restart also opens a new server connection.
test_pulse_stream_restart wraps pa_stream_new_with_proplist and
pa_stream_connect_record to make restarts fail on demand, and gains
three cases:
- the stream is killed and creating it fails 3 times while the device
stays: audio must return within 3 s, with 4 creation attempts;
- every connected stream is ended right after it is ready: restarts at
least PULSE_RESTART_RETRY_USEC apart, a give-up after at most
PULSE_RESTART_MAX_ATTEMPTS, no restart after that, and audio again
once a device appears;
- a source is destroyed while its restart is pending (control; the
group teardown checks for leaked weak references).
The 4 cases from obs-rust#378 and the control pass.
Refs obs-rust#1029.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A source restarts its stream when it fails while the server stays up (obs-rust#378), but: - if the restart fails synchronously (the stream cannot be created, connected or given a valid sample spec) while the device is there and the server is connected, nothing retries it until some device appears; - if the server keeps failing the restarted stream, the source restarts it at once every time, with no pause and no limit, each time on a new server connection (obs-rust#532). Route both through the restart counter the server reconnection already uses (pulse_restart_should_retry(), pulse_call_later()): - pulse_start_recording() now says why it failed: no server, no device, or anything else. A restart that fails while the device is there is retried every PULSE_RESTART_RETRY_USEC (100 ms). A missing device is still waited for (a new device event), so a device that is gone for good is not polled, and a lost server is still left to the reconnection, which retries missing devices as before. - A failed stream is restarted at once the first time and after PULSE_RESTART_RETRY_USEC after that. - Both count in the same restart_attempts. After PULSE_RESTART_MAX_ATTEMPTS (100) the source logs a warning, stops the stream and waits for a device to appear. - The counter is reset when the stream delivers audio, instead of when a start call returns, so a stream that starts and then fails right away keeps counting. The read callback runs with the mainloop locked, so the UI thread reads and writes the counter under pulse_lock(). - A pending per-stream retry does nothing if a device event restarted the stream meanwhile. The decisions are pulse_start_should_retry() and pulse_stream_failed_should_restart() in pulse-reconnect.c, which need no server; test_pulse_reconnect gains four cases for them (14 of 14). test_pulse_stream_restart: 7 of 7. Fixes obs-rust#1029. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
force-pushed
the
fix/pulse-restart-backoff-2
branch
from
October 16, 2026 08:51
998df8a to
fa6b7c5
Compare
zackees
enabled auto-merge
October 16, 2026 08:51
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 16, 2026
…bs-rust#1057) * test/cmocka: A dropped stream connection leaves its Pulse source silent (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]> * linux-pulseaudio: Restart a stream whose own connection was dropped 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]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Oct 16, 2026
Closed
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 #1029
What and why
An Audio Input or Output Capture on PulseAudio or PipeWire now retries a stream restart that fails while its device is there, and no longer restarts a stream that the server keeps failing in a loop. Both gaps are in our #378 (follow-up of #377), found in its review. Reproduced in 0.1.0-beta.20261014.
Cause
pulse_start_recording()(pulse_stream_event_task()). A synchronous failure (the stream cannot be created or connected, or the sample spec is invalid) with the device present is never retried. The source is silent until some device appears.pulse_stream_state_changed()), and nothing counts them. Since linux-pulseaudio: Give each capture stream a connection of its own #532 each restart also opens a new server connection.In the release (0.1.0-beta.20261014 AppImage, private PipeWire + WirePlumber + pipewire-pulse, an
LD_PRELOADshim that fails the same two libpulse calls as the test):Fix (all in
plugins/linux-pulseaudio)pulse_start_recording()now says why it failed: no server, no device, or anything else.PULSE_RESTART_RETRY_USEC(100 ms). A missing device is still waited for (a new device event), so a device that is gone for good is not polled. A lost server is still left to the reconnection, which retries missing devices as before.restart_attempts. AfterPULSE_RESTART_MAX_ATTEMPTS(100) the source logs "Giving up restarting ..., waiting for a device to appear", stops the stream and waits for a device event.pulse_lock().pulse-reconnect.c, which makes no context or stream calls:pulse_start_should_retry()andpulse_stream_failed_should_restart().Not changed
pulse_update()(choosing a device in the properties) still starts the stream once and does not retry a synchronous failure.pa_stream_connect_recordends the stream on the mainloop once it is ready. A real rejection reaches the same state callback. Asking pipewire-pulse to record from a device that does not exist did not fail the stream; it recorded from the default device.RED → GREEN
test/cmocka: Pulse stream restarts that fail are not retried or limited (RED).test_pulse_stream_restartwrapspa_stream_new_with_proplistandpa_stream_connect_recordand gains 3 cases.failed_restart_is_retriedandfailing_stream_is_paced_then_given_upfail every run, 5/5 in each lane: "'capture A' produced no audio within 3000 ms" and "the failing stream was restarted 52-54 times in 1 s, 15-18 ms apart at the least, expected 100 ms". The 4 cases from linux-pulseaudio: Restart an input whose stream dies while connected #378 and the destroy control pass. (Seen once under load, when the restarts came further apart: "still restarting the failing stream after 16 s (227 attempts)".)test_pulse_stream_restartwithENABLE_RUST_LIBOBSOFF and ON, 10/10 runs alone in each lane, every case run against the private server (no skips), 25 s per run (the give-up case waits out the 100 retries).test_pulse_reconnect14/14 (4 new cases for the decision functions; this one needs no server and runs in CI). With the 100 ms pause removed (*delay_usec = 0),failing_stream_is_paced_then_given_upfails ("52 times in 1 s, 16 ms apart"). Full ctest at-j8(private Xvfb, systemlibobs-openglmasked, TMPDIR unset): C lane 258/258, Rust lane 258/258. Skips:open_crashes_without_obs_corein both lanes, as on master; in the C lanetest_startup_cycle_stressalso skipped once under load and passed alone (not 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-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