Skip to content

fix: add init timeouts for PipeWire and PulseAudio#1194

Open
roderickvd wants to merge 2 commits into
masterfrom
fix/blocking-audio-servers
Open

fix: add init timeouts for PipeWire and PulseAudio#1194
roderickvd wants to merge 2 commits into
masterfrom
fix/blocking-audio-servers

Conversation

@roderickvd
Copy link
Copy Markdown
Member

(Hopefully) fixes #1192

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds initialization timeouts to the Linux audio backends to avoid cpal::default_host() hanging indefinitely (per #1192), allowing host selection to fall back when PipeWire/PulseAudio initialization stalls.

Changes:

  • PulseAudio: wrap pulseaudio::Client::from_env in a helper thread and fail host init after a fixed timeout.
  • PipeWire: introduce a fixed init timeout constant and add a watchdog to stop the PipeWire mainloop if done events never arrive; also reuse the constant for stream init waits.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/host/pulseaudio/mod.rs Adds a bounded wait around Client::from_env to prevent indefinite blocking during PulseAudio host initialization.
src/host/pipewire/device.rs Adds a PipeWire init watchdog (and shared init timeout constant) to avoid hangs during device discovery and stream initialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/host/pulseaudio/mod.rs Outdated
@roderickvd roderickvd force-pushed the fix/blocking-audio-servers branch from c94a90b to f5532e5 Compare May 9, 2026 13:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@marin-m
Copy link
Copy Markdown

marin-m commented May 9, 2026

works on my setup

@roderickvd
Copy link
Copy Markdown
Member Author

works on my setup

Just to be sure: was your setup hanging before too and is it now fixed?

@marin-m
Copy link
Copy Markdown

marin-m commented May 9, 2026

no issue on my setup but you requested me to test on the other ticket

@roderickvd
Copy link
Copy Markdown
Member Author

Yes would be great to hear from your users that suffered from it!

@marin-m
Copy link
Copy Markdown

marin-m commented May 11, 2026

My users are reporting that switching the default backend to ALSA in Flathub builds fixed the issue for them so I guess that the hanging point is likely to be here (if you want them to try with the non-Flathub builds feel free to ask them on the original tickets).

FYI the next release of SongRec should try both ALSA and PipeWire as a default backend, falling back to the next one when anything fails even in the late device acquisition process, and the first backend to be tried will heuristically depend on the distribution channel + a CLI flag (see marin-m/SongRec#306)

@roderickvd
Copy link
Copy Markdown
Member Author

Sounds good. I'll get this merged soon and hopefully it will aid marin-m/SongRec#306 or - best case - make it superfluous. Feel free to open a new issue if things pop up again.

@marin-m
Copy link
Copy Markdown

marin-m commented May 13, 2026

Noted, pushed your fix in rel 0.7.2 in the meantime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CPAL 0.18 devel with PipeWire enabled and PipeWire+PulseAudio running not working on FuriOS - Seems to block quietly on initialization

3 participants