Fix daemon autostart issue caused by sync pipewire retry loop (#43)

At boot time, PipeWire takes some time to register the `pwsp-daemon` and `pwsp-virtual-mic` devices. Previously, the daemon's retry loop for `link_player_to_virtual_mic()` was synchronous and limited to 5 attempts (1.5 seconds total). This caused systemd autostarts to fail with a code 1 if the devices were not yet available.

This change replaces the synchronous wait with an asynchronous `tokio::spawn` task. It will retry the link attempt up to 60 times with a 1-second delay without blocking the startup of the rest of the daemon. This prevents it from exiting abruptly during autostart.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Tarasov Aleksandr
2026-03-22 17:05:26 +03:00
committed by GitHub
parent 6114b9a7f8
commit f01a0e656c
5 changed files with 58 additions and 38 deletions
+8 -2
View File
@@ -58,7 +58,10 @@ impl SoundpadGui {
pub fn play_toggle(&mut self) {
let (new_state, request) = {
let guard = self.audio_player_state_shared.lock().unwrap_or_else(|e| e.into_inner());
let guard = self
.audio_player_state_shared
.lock()
.unwrap_or_else(|e| e.into_inner());
match guard.state {
PlayerState::Playing => (Some(PlayerState::Paused), Some(Request::pause(None))),
PlayerState::Paused => (Some(PlayerState::Playing), Some(Request::resume(None))),
@@ -71,7 +74,10 @@ impl SoundpadGui {
}
if let Some(state) = new_state {
let mut guard = self.audio_player_state_shared.lock().unwrap_or_else(|e| e.into_inner());
let mut guard = self
.audio_player_state_shared
.lock()
.unwrap_or_else(|e| e.into_inner());
guard.new_state = Some(state.clone());
guard.state = state;
}