From 6206a98428d907bdf493a0688836d1d13f57f32c Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 22 Feb 2026 15:21:29 -0600 Subject: [PATCH] fix: avoid redundant seeks in SetState to prevent audio hiccups When the server echoes back our own position in a SET_STATE command (e.g. after queue_load_tracks), seeking to the same position causes an audible hiccup. Skip the seek when the current position is within 2 seconds of the target. --- src-tauri/src/qconnect_service.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/qconnect_service.rs b/src-tauri/src/qconnect_service.rs index 61bb888e6..351ba0cd2 100644 --- a/src-tauri/src/qconnect_service.rs +++ b/src-tauri/src/qconnect_service.rs @@ -897,7 +897,18 @@ async fn apply_renderer_command_to_corebridge( } if let Some(position_ms) = renderer_state.current_position_ms.or(*current_position_ms) { - bridge.seek(position_ms / 1000)?; + let current_pos_secs = bridge.get_playback_state().position; + let target_secs = position_ms / 1000; + // Only seek if the position differs by more than 2 seconds to + // avoid audio hiccups from redundant seeks (e.g. when the server + // echoes back our own position in a SET_STATE after queue_load). + if current_pos_secs.abs_diff(target_secs) > 2 { + log::info!( + "[QConnect] SetState seek: current={}s target={}s", + current_pos_secs, target_secs + ); + bridge.seek(target_secs)?; + } } } RendererCommand::SetVolume { volume, .. } => {