# HG changeset patch # User jcdutton # Date 1030791927 0 # Node ID ba1121a071206073eb767c0c46261876ee9b3e48 # Parent 5716523464dda3e88cd20e438a1853e7e172032d Properly seed the DVD VM Instruction rand(). diff -r 5716523464dd -r ba1121a07120 dvdnav.c --- a/dvdnav.c Sat Aug 31 10:51:01 2002 +0000 +++ b/dvdnav.c Sat Aug 31 11:05:27 2002 +0000 @@ -38,6 +38,7 @@ #include #include +#include /* * NOTE: @@ -175,6 +176,7 @@ dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { dvdnav_t *this; + struct timeval time; /* Create a new structure */ fprintf(MSG_OUT, "libdvdnav: Using dvdnav version from http://dvd.sf.net\n"); @@ -216,7 +218,13 @@ /* Start the read-ahead cache. */ this->cache = dvdnav_read_cache_new(this); - + + /* Seed the random numbers. So that the DVD VM Command rand()i + * gives a different start value each time a DVD is played. + */ + gettimeofday(&time,NULL); + srand(time.tv_usec); + return S_OK; } @@ -990,6 +998,9 @@ /* * $Log$ + * Revision 1.33 2002/08/31 11:05:27 jcdutton + * Properly seed the DVD VM Instruction rand(). + * * Revision 1.32 2002/08/31 02:50:27 jcdutton * Improve some debug messages. * Add some comments about dvdnav_open memory leaks.