mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
d48ea819c1
* fix(player): freeze main seekbar during track preview Preview pauses the main sink in Rust while isPlaying stays true in the store, so WaveformSeek's interpolation rAF must not advance progress. * fix(audio): recover output after sleep and stalled streams Add platform-specific post-sleep recovery hooks for Windows and Linux, and add a watchdog that reopens the output stream when playback is active but sample progress stalls, so audio can recover without restarting the app. * fix(ui): remove card hover lift and smooth artwork zoom Remove vertical hover translation from album and artist cards, and move image fade transition out of inline styles so cover zoom uses CSS timing consistently. * fix(player): prevent seekbar jump after preview ends Reset interpolation anchor timing when preview freeze state changes so the main seekbar does not momentarily jump forward before resyncing. * fix(audio): reduce false watchdog recoveries and add diagnostics Arm stalled-output recovery only after long poll gaps that suggest sleep/resume, and add detailed watcher logs for arm/clear/trigger paths to diagnose unintended stream reopens. * chore(ui): drop card GPU hints and clarify macOS sleep scope Remove translateZ and will-change hints from album and artist cover images to avoid per-card compositing overhead on software-composited Linux paths, and document why post-sleep recovery hooks currently target only Windows and Linux. * docs(audio): document intentional Win32 callback pointer lifetime Add inline rationale for the two Box::into_raw pointers in Windows suspend/resume registration so future maintenance does not treat the process-lifetime pointers as accidental leaks. * docs(changelog): summarize playback stability updates for PR #476 Add a high-level changelog entry for preview seekbar fixes, sleep/wake audio recovery hooks and watchdog diagnostics, and card-hover stability adjustments from PR #476. * docs(contributors): add cucadmuh entry for PR #476 Logs the post-sleep audio recovery, preview-seekbar fixes and card hover stability work in the Settings → System → Contributors list.
91 lines
2.5 KiB
Rust
91 lines
2.5 KiB
Rust
//! Linux: subscribe to logind `PrepareForSleep` on the system bus — `start == false` means resume
|
|
//! completed (systemd says the boolean is true when going to sleep, false when waking).
|
|
|
|
use tauri::AppHandle;
|
|
|
|
use super::power_resume::{debounce_allow_resume_reopen, reopen_audio_after_system_resume};
|
|
|
|
pub fn register(app: AppHandle) {
|
|
let res = std::thread::Builder::new()
|
|
.name("psysonic-logind-sleep".into())
|
|
.spawn(move || run_listener(app));
|
|
|
|
if let Err(e) = res {
|
|
crate::app_eprintln!("[psysonic] could not spawn logind listener: {e}");
|
|
}
|
|
}
|
|
|
|
fn run_listener(app: AppHandle) {
|
|
use zbus::blocking::{Connection, MessageIterator};
|
|
use zbus::message::Type;
|
|
use zbus::MatchRule;
|
|
|
|
let conn = match Connection::system() {
|
|
Ok(c) => c,
|
|
Err(e) => {
|
|
crate::app_eprintln!(
|
|
"[psysonic] D-Bus system bus unavailable — post-sleep audio recovery disabled: {e}"
|
|
);
|
|
return;
|
|
}
|
|
};
|
|
|
|
let rule: zbus::MatchRule = match (|| -> zbus::Result<_> {
|
|
Ok(MatchRule::builder()
|
|
.msg_type(Type::Signal)
|
|
.path("/org/freedesktop/login1")?
|
|
.interface("org.freedesktop.login1.Manager")?
|
|
.member("PrepareForSleep")?
|
|
.build())
|
|
})() {
|
|
Ok(r) => r,
|
|
Err(e) => {
|
|
crate::app_eprintln!(
|
|
"[psysonic] MatchRule for logind PrepareForSleep failed: {e}"
|
|
);
|
|
return;
|
|
}
|
|
};
|
|
|
|
let mut iter = match MessageIterator::for_match_rule(rule, &conn, Some(32)) {
|
|
Ok(i) => i,
|
|
Err(e) => {
|
|
crate::app_eprintln!("[psysonic] logind signal subscription failed: {e}");
|
|
return;
|
|
}
|
|
};
|
|
|
|
crate::app_eprintln!("[psysonic] logind PrepareForSleep listener registered (post-sleep audio recovery)");
|
|
|
|
loop {
|
|
let Some(result) = iter.next() else {
|
|
break;
|
|
};
|
|
let msg = match result {
|
|
Ok(m) => m,
|
|
Err(e) => {
|
|
crate::app_eprintln!("[psysonic] logind message stream error: {e}");
|
|
break;
|
|
}
|
|
};
|
|
|
|
let start: bool = match msg.body().deserialize() {
|
|
Ok(b) => b,
|
|
Err(_) => continue,
|
|
};
|
|
|
|
if start {
|
|
continue;
|
|
}
|
|
|
|
if !debounce_allow_resume_reopen() {
|
|
continue;
|
|
}
|
|
|
|
let app = app.clone();
|
|
tauri::async_runtime::spawn(async move {
|
|
reopen_audio_after_system_resume(&app).await;
|
|
});
|
|
}
|
|
}
|