mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Revert 10 track history window
This commit is contained in:
parent
289b4f9bcc
commit
0f5d610b4b
1 changed files with 13 additions and 0 deletions
|
@ -84,6 +84,7 @@ struct SpircTaskConfig {
|
||||||
autoplay: bool,
|
autoplay: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CONTEXT_TRACKS_HISTORY: usize = 10;
|
||||||
const CONTEXT_FETCH_THRESHOLD: u32 = 5;
|
const CONTEXT_FETCH_THRESHOLD: u32 = 5;
|
||||||
|
|
||||||
const VOLUME_STEPS: i64 = 64;
|
const VOLUME_STEPS: i64 = 64;
|
||||||
|
@ -1051,9 +1052,21 @@ impl SpircTask {
|
||||||
let new_tracks = &context.tracks;
|
let new_tracks = &context.tracks;
|
||||||
debug!("Adding {:?} tracks from context to frame", new_tracks.len());
|
debug!("Adding {:?} tracks from context to frame", new_tracks.len());
|
||||||
let mut track_vec = self.state.take_track().into_vec();
|
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);
|
track_vec.extend_from_slice(new_tracks);
|
||||||
self.state
|
self.state
|
||||||
.set_track(protobuf::RepeatedField::from_vec(track_vec));
|
.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 {
|
} else {
|
||||||
warn!("No context to update from!");
|
warn!("No context to update from!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue