shithub: libopusenc

Download patch

ref: 2347d1570f016b15d4fa2afc641b77e5dfcda2a3
parent: b30da997ca1ba6d69815bd0ff06f15ecb03a5a6e
author: Jean-Marc Valin <[email protected]>
date: Tue May 2 11:48:47 EDT 2017

Calling srand() was probably not a good idea

Not a good thing to do from a library and if chains are short, we get the
same random number twice, which is even worse.

--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -275,15 +275,11 @@
 }
 
 static void init_stream(OggOpusEnc *enc) {
-  time_t start_time;
   assert(!enc->streams->stream_is_init);
   if (!enc->streams->serialno_is_set) {
-    start_time = time(NULL);
-    srand(((getpid()&65535)<<15)^start_time);
-
     enc->streams->serialno = rand();
   }
-  
+
   if (ogg_stream_init(&enc->streams->os, enc->streams->serialno) == -1) {
     assert(0);
     /* FIXME: How the hell do we handle that? */