[vlc-devel] [vlc-commits] commit: Fix randomisation algorithm. Thanks to jawbroken on IRC. ( Antoine Cellerier )

Toralf Niebuhr gmthor85 at aim.com
Fri Mar 5 22:19:06 CET 2010


Am 05.03.2010 um 21:59 schrieb Rémi Denis-Courmont:

> Le vendredi 5 mars 2010 20:36:14 git version control, vous avez écrit :
>> vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Fri Mar 
>> 5 11:34:42 2010 +0100| [d6547572772c97088bbd97a773d35565682b227c] |
>> committer: Antoine Cellerier
>> 
>> Fix randomisation algorithm. Thanks to jawbroken on IRC.
> 
> Please. Don't use rand(). Ever. Not thread-safe.
> 
> rand_r() is better. But even that's not really random unless properly seeded. 
> Therefore the same playlist will always be randomized to the same order.
> 
> Usually, vlc_rand_bytes() is much better, although overkill.
Can't you just generate a well suited random seed with that 'overkill'?
I worked on a simulation library ones and what we did was generating a list of good seeds; generated some good random int i and then took the ith seed.
The trouble with this is. If you need many independent good random number generators, you can't just generate a random seed for every generator. 
What you would need instead is a second seed list who's seeds are for a seed generator. This has actually a nice side effect. If you have got a bug that depends on the random number, you can just make the generator seed not random but still get semi randomness (with independence). This enables you to keep the same random numbers while fixing the bug.

> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> http://fi.linkedin.com/in/remidenis
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel




More information about the vlc-devel mailing list