playlist-shuffle input command is not random
- mpv version: mpv 0.34.0-365-g369168b9be
- Windows Version: Windows 10
- Source of the mpv binary: https://sourceforge.net/projects/mpv-player-windows/files
Reproduction steps
- Create
input.confwith a line<some key> loadlist playlist.txt; playlist-shuffle; playlist-next, whereplaylist.txtis a newline-separated list of audio files. Please note this is specifically related toinput.conf. The behavior may be different when shuffle is issued via command line option--shuffle. - Run mpv.exe.
- Press the configured key as in
input.conf. - Check the order of files in the current playlist.
Expected behavior
The playlist order should not be the same each time the above sequence of steps is performed, with high probability.
Actual behavior
The playlist order is the same each time.
Log file
The playlist-shuffle command calls the C standard library rand() which is a pseudo-random number generator. According to the manpages, rand() will use a seed of 1 unless srand() is called first, which in this case it is not. This gives us deterministic behavior since srand() is not called here.
I agree that this is a bug that should be fixed, since this behavior isn't required for playlist-unshuffle to work. We could always srand() with something non-cryptographic like system wallclock time to make this work.
See if this is fixed after 52e7269ea633b7ac3d83d7b5cba9b15c5fbcbef9
Tested it, it is.