[xiph-commits] r15375 - in trunk/vorbis-tools: . oggenc

ivo at svn.xiph.org ivo at svn.xiph.org
Sat Oct 4 14:15:15 PDT 2008


Author: ivo
Date: 2008-10-04 14:15:15 -0700 (Sat, 04 Oct 2008)
New Revision: 15375

Modified:
   trunk/vorbis-tools/CHANGES
   trunk/vorbis-tools/oggenc/oggenc.c
Log:
Include the PID in the RNG seed to get a unique serial.  We are using getpid() here, since I heard contradictory statements regarding Windows support of getpid(); will add a _getpid() on a #ifdef WIN32 if it turns out it doesn't work on Windows.  Patch by Michael Gold.  Closes #1432

Modified: trunk/vorbis-tools/CHANGES
===================================================================
--- trunk/vorbis-tools/CHANGES	2008-10-04 20:59:42 UTC (rev 15374)
+++ trunk/vorbis-tools/CHANGES	2008-10-04 21:15:15 UTC (rev 15375)
@@ -11,7 +11,7 @@
  * ogg123: backported fix from libfishsound to patch the Speex decoder (#1347)
  * ogg123: fixed CPU issue when outputting to a closed pipe (#1357)
  * ogg123: return value to stop decoding after buffer is shut down (#1357)
- * ogg123: support for ReplayGain (#381)
+ * ogg123: support for ReplayGain; requires libvorbis 1.2.1 or later (#381)
  * oggdec: gettextized help text (#1385)
  * oggdec: gettextized all strings
  * oggdec: call ov_open_callbacks instead of ov_open; it works on Windows now
@@ -25,6 +25,7 @@
  * oggenc: --utf8 command similar to vorbiscomment's --raw (#268)
  * oggenc: fixed the encoding of extended characters in Windows (#268)
  * oggenc: validate raw UTF-8 sent to oggenc (#268)
+ * oggenc: include the PID in the RNG seed to get a unique serial (#1432)
  * ogginfo: support for information in Kate streams (#1360)
  * vcut: 64 bit fixes (#1366)
  * vorbiscomment: correct memory allocation (#472)

Modified: trunk/vorbis-tools/oggenc/oggenc.c
===================================================================
--- trunk/vorbis-tools/oggenc/oggenc.c	2008-10-04 20:59:42 UTC (rev 15374)
+++ trunk/vorbis-tools/oggenc/oggenc.c	2008-10-04 21:15:15 UTC (rev 15375)
@@ -21,6 +21,11 @@
 #include <time.h>
 #include <locale.h>
 #include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#if defined WIN32 || defined _WIN32
+#include <process.h>
+#endif
 
 #include "platform.h"
 #include "encode.h"
@@ -128,8 +133,10 @@
 
     if(!opt.fixedserial)
     {
-        /* We randomly pick a serial number. This is then incremented for each file */
-        srand(time(NULL));
+                /* We randomly pick a serial number. This is then incremented for each
+                   file. The random seed includes the PID so two copies of oggenc that
+                   start in the same second will generate different serial numbers. */
+                srand(time(NULL) ^ getpid());
         opt.serial = rand();
         opt.skeleton_serial = opt.serial + numfiles;
     }



More information about the commits mailing list