GNOME Bugzilla – Bug 745647
shuffleHistory fixes
Last modified: 2015-03-05 10:36:40 UTC
On commit 6f1cb8d448d8 I happened to break _get_previous_song() for shuffled items, _get_next_song() is since called early when playing a song, this makes the current song added early to the queue, so _get_previous_song() always pops the current one. I'm attaching a patch that fixes this, and switches to using deque. Using a LIFO, each time gnome-music made space for the new item on overflow, it was practically only replacing the most recently added item. Using deque both handles overflow for us, and behaves as a FIFO in this case, which is just right to preserve the last shuffle items.
Created attachment 298589 [details] [review] player: Use a deque for the shuffle history deque seems better for the task, as we actually want to pop elements as a FIFO so we forget about the oldest song and not the most recent in order to add the most recent one. This is something managed automatically by deque when setting a maxlen. Also, commit 6f1cb8d448d8 changed player behavior so _get_next_track() is called early after currentTrack changes, this means that the current track is added very early to the shuffle list, so was always mistakenly popped as the "previous" song. Make this behave nicely and either return the actual previous song, or "rewind" if we played more than 10s of the song.
Not sure if I personally like the 10 secs change, we'll see if that works for most people. Pushed as https://git.gnome.org/browse/gnome-music/commit/?id=067a964, thanks!