From b13ab3aa1b713e2a586890791050be6e11f4a746 Mon Sep 17 00:00:00 2001 From: Felix Prillwitz Date: Thu, 12 Dec 2024 17:33:15 +0100 Subject: [PATCH] connect: fix incorrect stopping --- connect/src/spirc.rs | 3 +-- connect/src/state.rs | 6 ++++++ connect/src/state/tracks.rs | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index bd8fc962..1d7f7a63 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -1042,7 +1042,7 @@ impl SpircTask { self.connect_state.update_position(0, self.now_ms()); self.connect_state.clear_next_tracks(true); - if let Err(why) = self.connect_state.fill_up_next_tracks() { + if let Err(why) = self.connect_state.reset_playback_to_position(None) { warn!("failed filling up next_track during stopping: {why}") } } @@ -1343,7 +1343,6 @@ impl SpircTask { self.load_track(continue_playing, 0) } else { info!("Not playing next track because there are no more tracks left in queue."); - self.connect_state.reset_playback_to_position(None)?; self.handle_stop(); Ok(()) } diff --git a/connect/src/state.rs b/connect/src/state.rs index a132e479..2c1bf944 100644 --- a/connect/src/state.rs +++ b/connect/src/state.rs @@ -348,9 +348,15 @@ impl ConnectState { } pub fn reset_playback_to_position(&mut self, new_index: Option) -> Result<(), Error> { + debug!( + "reset_playback with active ctx <{:?}> fill_up ctx <{:?}>", + self.active_context, self.fill_up_context + ); + let new_index = new_index.unwrap_or(0); self.update_current_index(|i| i.track = new_index as u32); self.update_context_index(self.active_context, new_index + 1)?; + self.fill_up_context = self.active_context; if !self.current_track(|t| t.is_queue()) { self.set_current_track(new_index)?; diff --git a/connect/src/state/tracks.rs b/connect/src/state/tracks.rs index fae36bc8..499446bb 100644 --- a/connect/src/state/tracks.rs +++ b/connect/src/state/tracks.rs @@ -333,6 +333,11 @@ impl<'ct> ConnectState { self.next_tracks_mut().push(track); } + debug!( + "finished filling up next_tracks ({})", + self.next_tracks().len() + ); + self.update_context_index(self.fill_up_context, new_index)?; // the web-player needs a revision update, otherwise the queue isn't updated in the ui