Skip to content

Fix deterministic playlist shuffling by migrating to modern C++ std::shuffle (Fixes #756) - #879

Open
dhruvajshetty wants to merge 1 commit into
tizonia:masterfrom
dhruvajshetty:master
Open

dhruvajshetty wants to merge 1 commit into
tizonia:masterfrom
dhruvajshetty:master

Conversation

@dhruvajshetty

Copy link
Copy Markdown

Description

This PR fixes issue #756 where local playback playlists were consistently shuffled in the identical order upon initialization.

What was changed

The root cause was the usage of the deprecated std::random_shuffle. Depending on the platform implementation, it often relies on an underlying generator that wasn't being correctly influenced by the std::srand(time(nullptr)) seed on startup.

I updated the shuffle logic in tizplaylist.cpp to use the modern C++11 <random> library:

  • Added #include <random>
  • Replaced std::random_shuffle with std::shuffle
  • Introduced std::random_device and a std::mt19937 Mersenne Twister engine to guarantee true randomized seeding on every execution.

Related Issue

Fixes #756

@juanrubio

Copy link
Copy Markdown
Member

Thanks for picking this up, @dhruvajshetty, and for opening PR #879. We’re doing a broad v1 revival in parallel, so this area may change and the patch might need adapting; I don’t want to promise it can be merged unchanged. But contributions are very welcome, and it’s great to have something concrete to review. We’ll coordinate the review with the ongoing work—thanks for getting involved.

@dhruvajshetty

Copy link
Copy Markdown
Author

Thank you, let me know if any change is required from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local playback: playlists are shuffled always in the same way

2 participants