Skip to content

Fix "Could not find default hardware sink" race after Maxine restart - #5

Merged
londospark merged 1 commit into
mainfrom
fix-hardware-sink-race-after-restart
Sep 2, 2026
Merged

londospark merged 1 commit into
mainfrom
fix-hardware-sink-race-after-restart

Conversation

@londospark

Copy link
Copy Markdown
Owner

Summary

  • set_maxine_enabled() restarts pipewire, pipewire-pulse, and wireplumber every time the Maxine backend is toggled on/off.
  • WirePlumber re-enumerates ALSA cards asynchronously after those restarts, so the real hardware sink is briefly absent from pactl list sinks (only the filter's own virtual sink shows up).
  • set_filter_active → apply_routes ran immediately after the restart with no delay, so find_default_sink_name reliably hit this window and failed with "Could not find default hardware sink" — leaving broadcast stuck off.
  • Added wait_for_hardware_sink(), a short best-effort poll (200ms interval, 8s cap) after the restart cascade in set_maxine_enabled, so callers only proceed once a real hardware sink is present again.

Test plan

  • cargo test -p broadcast-core -p broadcast-ctl (77 tests pass)
  • Reproduced the bug live (broadcast-ctl on → Error: Could not find default hardware sink), confirmed pactl only reports the filter's virtual sink immediately after a pipewire/wireplumber restart cascade and recovers ~1s later
  • Built the patched binary, installed it, and confirmed broadcast-ctl on/off now succeed reliably with Health: OK and correct default sink/source

…axine

set_maxine_enabled() restarts pipewire, pipewire-pulse, and wireplumber
every time the Maxine backend is toggled, but WirePlumber re-enumerates
ALSA cards asynchronously after those restarts. apply_routes() ran
immediately afterward and would see only the filter's own virtual sink
for up to ~1-2s, failing with "Could not find default hardware sink"
and leaving broadcast stuck off. Poll pactl briefly after the restart
cascade until a real hardware sink reappears before returning.
@londospark
londospark merged commit f04813f into main Sep 2, 2026
1 check passed
@londospark
londospark deleted the fix-hardware-sink-race-after-restart branch September 10, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant