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
This commit is contained in:
2 files changed
+13
No files matched your search
@@ -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::<NowPlayingState>();
|
||||
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
|
||||
|
||||
@@ -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<i32>,
|
||||
}
|
||||
|
||||
/// 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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user