From a1b054c3871d37990d8d85b646b686898de0cc11 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Wed, 3 Jun 2026 10:46:30 -0600 Subject: [PATCH] feat(qbz-slint): reflect peer volume on the bar with a 50% safety clamp When controlling a peer renderer, the volume slider must reflect the PEER's actual volume, never QBZ's local 100, so a drag starts from a safe level and never nukes the AVR. Extend RemoteNowPlaying with the peer's reported volume (sourced from the effective remote renderer snapshot) and, in the poll loop's peer-reflection branch, push it to NowPlayingState.volume as v/100 (clamped 0..1), falling back to 0.5 (50%) when the peer's volume is unknown. This branch only runs when a peer is active, so local/renderer playback is unaffected. cc --- crates/qbz-slint/src/playback.rs | 8 ++++++++ crates/qbz-slint/src/qconnect_service.rs | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/crates/qbz-slint/src/playback.rs b/crates/qbz-slint/src/playback.rs index 12a5a06e1..813c27234 100644 --- a/crates/qbz-slint/src/playback.rs +++ b/crates/qbz-slint/src/playback.rs @@ -2033,6 +2033,13 @@ pub fn start_poll_loop( let elapsed = fmt_elapsed(position_secs); let remaining = fmt_remaining(position_secs, duration_secs); let playing = remote.playing; + // Reflect the PEER's actual volume on the bar so a drag starts + // from a safe level (never QBZ's local 100). When the peer hasn't + // reported a volume, clamp to 50% — the AVR-nuke safety default. + let remote_volume = remote + .volume + .map(|v| (v as f32 / 100.0).clamp(0.0, 1.0)) + .unwrap_or(0.5); let _ = weak.upgrade_in_event_loop(move |w| { let np = w.global::(); np.set_position_secs(position_secs as i32); @@ -2044,6 +2051,7 @@ pub fn start_poll_loop( np.set_elapsed(elapsed.into()); np.set_remaining(remaining.into()); np.set_playing(playing); + np.set_volume(remote_volume); }); // Reset the LOCAL edge trackers so when control returns to QBZ // the end-of-track / gapless / transition logic re-detects from a diff --git a/crates/qbz-slint/src/qconnect_service.rs b/crates/qbz-slint/src/qconnect_service.rs index fa1775b07..54027a7b9 100644 --- a/crates/qbz-slint/src/qconnect_service.rs +++ b/crates/qbz-slint/src/qconnect_service.rs @@ -72,6 +72,10 @@ pub struct RemoteNowPlaying { pub position_ms: u64, pub updated_at_ms: u64, pub playing: bool, + /// Peer renderer's reported volume (0..=100). `None` when the peer hasn't + /// reported a volume yet — the bar then clamps to a safe 50% instead of + /// reflecting QBZ's local 100, so a drag never nukes the AVR. + pub volume: Option, } /// Process-wide QConnect service singleton (one per app, like the playback @@ -803,6 +807,7 @@ impl SlintQconnectService { position_ms: renderer.current_position_ms.unwrap_or(0), updated_at_ms: renderer.updated_at_ms, playing: renderer.playing_state == Some(PLAYING_STATE_PLAYING), + volume: renderer.volume, }) }