Open juanrubio opened 4 years ago
The solution is to seed the random generator before shuffling the list: https://stackoverflow.com/questions/14221763/stdrandom-shuffle-produces-same-result-each-time
Hey, i'm a newbie to open source and i want to work on this issue. Please guide me further
This issue can be closed, as this is already fixed by #766.
Yeah but the last fix used a srand() in the function itself which is not the most optimal way to regenerate a seed.
Yeah but the last fix used a srand() in the function itself which is not the most optimal way to regenerate a seed.
@onio-rgb Could you please elaborate a bit more? Why srand() here is bad and what would be more optimal?
Issue
Description
As reported in Gitter by user @evilblade666
Hi, guys. My home internet is down for a time here, so I'm listening for my local music and I've noticed a thing.. So the command is tizonia /path/to/local/music/folder/ -r -s Well, it plays and shuffles my entire music allright, BUT! it shuffles it the same way EVERY time! :) Only when I modify the contents of a folder by adding/removing something - then the playlist becomes different :) Can I do something to make this shuffled playlist different every time I run the command?
The problem seems to be that the random generator is not seeded before calling
std::random_shuffle
in:https://github.com/tizonia/tizonia-openmax-il/blob/ca7e48a392618e5d1dee3e388cc15fad5eaa66c3/player/src/tizplaylist.cpp#L231
Steps to Reproduce
tizonia ~/Music --shuffle
. Observe the playlist created.Expected behavior:
Correctly randomized playlists every time.
Reproduces how often:
Always
Versions
Latest (0.22.0)
Installation Method Used
Any