Repository navigation
Description
Follow-up of #377 / #378, found in review of #378 (not an upstream report). When an Audio Input or Output Capture's own stream fails while the connection to the sound server stays up, #378 restarts it once. Two cases around that restart are not handled:
- The restart fails synchronously while the device is there and the server is connected (the stream cannot be created or connected, or the sample spec is invalid). Nothing retries it: the source stays silent until some device appears on the server or its settings change.
- The server keeps failing the restarted stream. Each failure restarts it at once, with no pause and no limit, so the source restarts in a loop on the UI thread for as long as the server keeps doing that. Since linux-pulseaudio: Give each capture stream a connection of its own #532 each restart also opens a new connection to the server.
Location
plugins/linux-pulseaudio/pulse-input.cline 519,pulse_stream_event_task(): the per-stream restart callspulse_start_recording(data)and ignores its result.- Same file, line 557,
pulse_stream_state_changed(): every failure of a stream queues another restart, and nothing counts them. - Compare line 413,
pulse_restart_recording_task()(the server reconnection path from plugins: Reconnect Linux capture after PipeWire restarts #109): it retries a failed start withpulse_restart_should_retry()andpulse_call_later(), every 100 ms, up to 100 attempts. plugins/linux-pulseaudio/pulse-reconnect.hline 69: "Each event leads to at most one start attempt, so a device that is gone for good is not polled." That is right for a missing device, but it also drops a start that failed for another reason.
Reproduced in 0.1.0-beta.20261014
The released AppImage (built from 9e2325e), headless: private PipeWire, WirePlumber and pipewire-pulse with no hardware, an Audio Input Capture on a virtual source, and a small LD_PRELOAD shim around pa_stream_new_with_proplist and pa_stream_connect_record that makes them fail on demand:
- Stream killed (
pw-cli destroy) and the next 3 stream creations set to fail: OBS logs "Stream from '...' failed, restarting it", then one "Unable to create stream", then nothing. No second attempt in 5 s. The source records again only after an unrelated device is added to the server. Same result in each of 3 recorded runs. - Every connected stream ended as soon as it is ready (a server that keeps failing it): 88 to 94 restarts in the first second and 1323 to 1398 in 15 s (two runs on an idle host), 19 and 395 in a run while the host was busy compiling. "Giving up" never appears, and each restart logs 6 lines. It stops only when the failure stops.
Current master has the same code (no change to plugins/linux-pulseaudio since 9e2325e).
Class
Silent audio loss (case 1), or a busy UI thread, a new server connection every few milliseconds and a growing log (case 2). No crash. Both need an unusual server or client state: a synchronous failure while the device is listed, or a server that rejects every new stream. No real-world trigger is known; #378 made things strictly better (before it, every per-stream failure was permanent). Likelihood is low, but the retry code that covers both is already there.
Proposed fix
Send per-stream restart failures and repeated stream failures through the existing counter. A start that fails while the device is there is retried every 100 ms. A failed stream is restarted at once the first time and after 100 ms after that. Both count towards the same 100-attempt limit, after which the source logs a warning and waits for a device to appear. A missing device is still waited for (not polled), and a lost server is still left to the reconnection. The counter resets when the stream delivers audio.
RED tests:
test_pulse_stream_restart(private PipeWire, no hardware, no display) wraps the same two calls and gains 3 cases: a failed restart is retried; a failing stream is restarted at least 100 ms apart, given up after the limit and started again when a device appears; a source destroyed while a retry is pending leaks nothing. 2 of 7 fail today. The 4 existing cases and the destroy control pass. It skips in CI (the Tier 2 image has no PipeWire), like the existing cases.test_pulse_reconnect(no server; runs in CI): 4 cases for the new decision functions, added with the fix.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 16, 2026
Claiming: this issue.
This is a follow-up of our #378, so the fix stays inside
plugins/linux-pulseaudio:test_pulse_stream_restartmakes stream creation and connection fail on demand. One case kills the stream and fails its next 3 creations: audio must come back within 3 s. One case fails every connected stream: restarts must be at least 100 ms apart, must stop afterPULSE_RESTART_MAX_ATTEMPTS, and must start again when a device appears. A third case destroys a source while its retry is pending. Today the first two fail.pulse-reconnect.cget their own cases intest_pulse_reconnect, which runs in CI.test/cmocka: Pulse stream restarts that fail are not retried or limit…
linux-pulseaudio: Retry failed stream restarts with a pause and a limit
test/cmocka: Pulse stream restarts that fail are not retried or limit…
linux-pulseaudio: Retry failed stream restarts with a pause and a limit
linux-pulseaudio: Retry failed stream restarts with a pause and a lim…