[MPlayer-dev-eng] [PATCH] fix last file with -shuffle
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Nov 5 19:29:12 CET 2004
Hi,
this patch fixes the problem that the file specified last is almost
always played last.
This was cause by incorrect random number range conversion
(thanks to the manpage people for the example in the rand manpage that
made me think once again ;-) )
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: playtree.c
===================================================================
RCS file: /cvsroot/mplayer/main/playtree.c,v
retrieving revision 1.22
diff -u -r1.22 playtree.c
--- playtree.c 20 Oct 2004 17:30:29 -0000 1.22
+++ playtree.c 5 Nov 2004 20:36:40 -0000
@@ -525,7 +525,7 @@
if(!count) return NULL;
- r = (int)((count-1.0) * rand() / RAND_MAX);
+ r = (int)((float)(count) * rand() / (RAND_MAX + 1.0));
for(i = head ; i ; i=i->next) {
if(!(i->flags & PLAY_TREE_RND_PLAYED)) r--;
More information about the MPlayer-dev-eng
mailing list