Mercurial > libdvdnav.hg
comparison dvdnav.c @ 84:ba1121a07120 src
Properly seed the DVD VM Instruction rand().
author | jcdutton |
---|---|
date | Sat, 31 Aug 2002 11:05:27 +0000 |
parents | 033f011d8152 |
children | 0fbef4901e2c |
comparison
equal
deleted
inserted
replaced
83:5716523464dd | 84:ba1121a07120 |
---|---|
36 | 36 |
37 #include <dvdread/nav_read.h> | 37 #include <dvdread/nav_read.h> |
38 | 38 |
39 #include <stdlib.h> | 39 #include <stdlib.h> |
40 #include <stdio.h> | 40 #include <stdio.h> |
41 #include <sys/time.h> | |
41 | 42 |
42 /* | 43 /* |
43 * NOTE: | 44 * NOTE: |
44 * All NLCK_*() function are not mutex locked, this made them reusable in | 45 * All NLCK_*() function are not mutex locked, this made them reusable in |
45 * a locked context. Take care. | 46 * a locked context. Take care. |
173 return S_OK; | 174 return S_OK; |
174 } | 175 } |
175 | 176 |
176 dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { | 177 dvdnav_status_t dvdnav_open(dvdnav_t** dest, char *path) { |
177 dvdnav_t *this; | 178 dvdnav_t *this; |
179 struct timeval time; | |
178 | 180 |
179 /* Create a new structure */ | 181 /* Create a new structure */ |
180 fprintf(MSG_OUT, "libdvdnav: Using dvdnav version from http://dvd.sf.net\n"); | 182 fprintf(MSG_OUT, "libdvdnav: Using dvdnav version from http://dvd.sf.net\n"); |
181 | 183 |
182 /* FIXME: We malloc() here, but if an error occurs inside dvdnav_open(), | 184 /* FIXME: We malloc() here, but if an error occurs inside dvdnav_open(), |
214 if (this->file) DVDCloseFile(this->file); | 216 if (this->file) DVDCloseFile(this->file); |
215 this->file = NULL; | 217 this->file = NULL; |
216 | 218 |
217 /* Start the read-ahead cache. */ | 219 /* Start the read-ahead cache. */ |
218 this->cache = dvdnav_read_cache_new(this); | 220 this->cache = dvdnav_read_cache_new(this); |
219 | 221 |
222 /* Seed the random numbers. So that the DVD VM Command rand()i | |
223 * gives a different start value each time a DVD is played. | |
224 */ | |
225 gettimeofday(&time,NULL); | |
226 srand(time.tv_usec); | |
227 | |
220 return S_OK; | 228 return S_OK; |
221 } | 229 } |
222 | 230 |
223 dvdnav_status_t dvdnav_close(dvdnav_t *this) { | 231 dvdnav_status_t dvdnav_close(dvdnav_t *this) { |
224 if(!this) { | 232 if(!this) { |
988 return this->position_next.still; | 996 return this->position_next.still; |
989 } | 997 } |
990 | 998 |
991 /* | 999 /* |
992 * $Log$ | 1000 * $Log$ |
1001 * Revision 1.33 2002/08/31 11:05:27 jcdutton | |
1002 * Properly seed the DVD VM Instruction rand(). | |
1003 * | |
993 * Revision 1.32 2002/08/31 02:50:27 jcdutton | 1004 * Revision 1.32 2002/08/31 02:50:27 jcdutton |
994 * Improve some debug messages. | 1005 * Improve some debug messages. |
995 * Add some comments about dvdnav_open memory leaks. | 1006 * Add some comments about dvdnav_open memory leaks. |
996 * | 1007 * |
997 * Revision 1.31 2002/08/27 19:15:08 mroi | 1008 * Revision 1.31 2002/08/27 19:15:08 mroi |