Commit Graph

20 Commits

Author SHA1 Message Date
Vittorio Giovara
41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Michael Niedermayer
01d245ef43 random_seed: Rewrite the generic clock() based seed code
The new code is faster and reuses the previous state in case of
multiple calls.

The previous code could easily end up in near-infinite loops,
if the difference between two clock() calls never was larger than
1.

This makes fate-parseutils finish in finite time when run in wine,
if CryptGenRandom isn't available (which e.g. isn't available if
targeting Windows RT/metro).

Patch originally by Michael Niedermayer but with some modifications
by Martin Storsjö.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-01-06 18:53:58 +02:00
Rémi Denis-Courmont
880391ed2d libavutil: use avpriv_open()
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2013-08-07 21:12:28 +02:00
Martin Storsjö
1093383d6c random_seed: Support using CryptGenRandom on windows
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-10-11 18:49:34 +03:00
Ronald S. Bultje
f985113075 random_seed: Only read /dev/*random if we have unistd.h
unistd.h is used for open/read/close, but if this header does not
exist, there's probably no use in trying to open /dev/*random
at all.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-06-29 15:52:07 +03:00
Yordan Makariev
425b45d4b0 Code clean-up for crc.c, lfg.c, log.c, random_see.d, rational.c and tree.c.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2011-12-03 15:13:48 -08:00
Mans Rullgard
172ee1da2b random_seed: use proper #includes
Use <> for system headers, add needed math.h, drop unnecessary avutil.h.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-07-17 20:47:39 +01:00
Anton Khirnov
975c273405 lavu: remove disabled ff_random_get_seed cruft. 2011-04-19 21:50:12 +02:00
Mans Rullgard
2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Michael Niedermayer
6a522c49c2 Fix infinite loop with clock() returning (clock_t)-1.
Originally committed as revision 24116 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-08 18:13:31 +00:00
Michael Niedermayer
b65c1ccfe1 Change i to unsigned in get_generic_seed().
This is clearer than comparing against an unsigned number to force an unsigned
comparison that we need.

Originally committed as revision 24114 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-08 17:49:39 +00:00
Michael Niedermayer
c84d5aa74f get_generic_seed() for the cases without /dev/random and AV_READ_TIME
Originally committed as revision 24102 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-07 23:47:48 +00:00
Måns Rullgård
16bfbfd078 random_seed: simplify
Originally committed as revision 23932 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-01 11:43:30 +00:00
Måns Rullgård
9958096ea2 Reindent
Originally committed as revision 23931 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-01 11:40:54 +00:00
Måns Rullgård
b7fa5c5abb random_seed: allow to block on /dev/random
If both /dev/random and /dev/urandom failed to return data, an
uninitialised value might be returned.  Since most systems have a
non-blocking /dev/urandom or have /dev/random with similar properties,
the chance of blocking is minimal, and the alternative of returning
non-random data is worse.

Originally committed as revision 23930 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-01 11:40:50 +00:00
Måns Rullgård
38e23c88db Make av_get_random_seed() non-blocking
Attempt to read from /dev/urandom and /dev/random with O_NONBLOCK set.
If neither succeeds, proceed with fallbacks.

Originally committed as revision 23903 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-30 10:38:04 +00:00
Martin Storsjö
576fb48e6d Make ff_random_get_seed public, rename to av_get_random_seed, export the header
Keep an old ff_ named function for binary compatibility until the
next major bump.

Originally committed as revision 23254 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-05-23 08:53:40 +00:00
Måns Rullgård
5de91783bf indent
Originally committed as revision 22451 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 02:32:14 +00:00
Måns Rullgård
49e9287878 random_seed: try other alternatives if reading /dev/random fails
Originally committed as revision 22450 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-03-11 02:32:11 +00:00
Baptiste Coudurier
48d58e592a add ff_random_get_seed to be used in conjunction with random functions
Originally committed as revision 17868 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-03-08 01:28:14 +00:00