[MPlayer-dev-eng] [PATCH] fix last file with -shuffle

D Richard Felker III dalias at aerifal.cx
Fri Nov 5 23:38:21 CET 2004


On Fri, Nov 05, 2004 at 07:29:12PM +0100, Reimar Döffinger wrote:
> 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

please apply....although i think rand()%count would make a lot more
sense. maybe not entirely correct though. :)

rich




> 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--;

> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng




More information about the MPlayer-dev-eng mailing list