mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
SoundPlayer: Implement playlist shuffle mode
The shuffling algorithm uses a naïve bloom filter to provide random uniformity, avoiding items that were recently played. With 32 bits, double hashing, and an error rate of ~10%, this bloom filter should be able to hold around ~16 keys, which should be sufficient to give the illusion of fairness to the shuffling algorithm. This avoids having to shuffle the playlist itself (user might have spent quite a bit of time to sort them, so it's not a good idea to mess with it), or having to create a proxy model that shuffles (that could potentially use quite a bit of memory).
This commit is contained in:
parent
0812965f50
commit
314b8a374b
7 changed files with 106 additions and 11 deletions
|
@ -92,6 +92,15 @@ void Player::set_volume(double volume)
|
|||
volume_changed(m_volume);
|
||||
}
|
||||
|
||||
void Player::set_shuffle_mode(ShuffleMode mode)
|
||||
{
|
||||
if (m_shuffle_mode != mode) {
|
||||
m_shuffle_mode = mode;
|
||||
m_playlist.set_shuffling(mode == ShuffleMode::Shuffling);
|
||||
shuffle_mode_changed(mode);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::play()
|
||||
{
|
||||
m_playback_manager.play();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue