diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc3f9cc..196b4e88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [connect] Fix step size on volume up/down events +- [connect] Fix looping back to the first track after the last track of an album or playlist - [playback] Incorrect `PlayerConfig::default().normalisation_threshold` caused distortion when using dynamic volume normalisation downstream - [playback] Fix `log` and `cubic` volume controls to be mute at zero volume - [playback] Fix `S24_3` format on big-endian systems diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index 9aa86134..2038c8bd 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -84,7 +84,6 @@ struct SpircTaskConfig { autoplay: bool, } -const CONTEXT_TRACKS_HISTORY: usize = 10; const CONTEXT_FETCH_THRESHOLD: u32 = 5; const VOLUME_STEPS: i64 = 64; @@ -887,8 +886,8 @@ impl SpircTask { let tracks_len = self.state.get_track().len() as u32; debug!( "At track {:?} of {:?} <{:?}> update [{}]", - new_index, - self.state.get_track().len(), + new_index + 1, + tracks_len, self.state.get_context_uri(), tracks_len - new_index < CONTEXT_FETCH_THRESHOLD ); @@ -902,27 +901,25 @@ impl SpircTask { self.context_fut = self.resolve_station(&context_uri); self.update_tracks_from_context(); } - let last_track = new_index == tracks_len - 1; - if self.config.autoplay && last_track { - // Extend the playlist - // Note: This doesn't seem to reflect in the UI - // the additional tracks in the frame don't show up as with station view - debug!("Extending playlist <{}>", context_uri); - self.update_tracks_from_context(); - } if new_index >= tracks_len { - new_index = 0; // Loop around back to start - continue_playing = self.state.get_repeat(); + if self.config.autoplay { + // Extend the playlist + debug!("Extending playlist <{}>", context_uri); + self.update_tracks_from_context(); + self.player.set_auto_normalise_as_album(false); + } else { + new_index = 0; + continue_playing = self.state.get_repeat(); + debug!( + "Looping around back to start, repeat is {}", + continue_playing + ); + } } if tracks_len > 0 { self.state.set_playing_track_index(new_index); self.load_track(continue_playing, 0); - if self.config.autoplay && last_track { - // If we're now playing the last track of an album, then - // switch to track normalisation mode for the autoplay to come. - self.player.set_auto_normalise_as_album(false); - } } else { info!("Not playing next track because there are no more tracks left in queue."); self.state.set_playing_track_index(0); @@ -1054,21 +1051,9 @@ impl SpircTask { let new_tracks = &context.tracks; debug!("Adding {:?} tracks from context to frame", new_tracks.len()); let mut track_vec = self.state.take_track().into_vec(); - if let Some(head) = track_vec.len().checked_sub(CONTEXT_TRACKS_HISTORY) { - track_vec.drain(0..head); - } track_vec.extend_from_slice(new_tracks); self.state .set_track(protobuf::RepeatedField::from_vec(track_vec)); - - // Update playing index - if let Some(new_index) = self - .state - .get_playing_track_index() - .checked_sub(CONTEXT_TRACKS_HISTORY as u32) - { - self.state.set_playing_track_index(new_index); - } } else { warn!("No context to update from!"); }