
$FreeBSD: ports/audio/mpg123/files/patch-ab,v 1.6 2001/08/21 16:58:33 sobomax Exp $

--- mpg123.c.orig	Tue Aug 21 19:48:17 2001
+++ mpg123.c	Tue Aug 21 19:49:02 2001
@@ -27,6 +27,10 @@
 #include <sched.h>
 #endif
 
+#ifdef __FreeBSD__
+#include <ieeefp.h>
+#endif
+
 #include "mpg123.h"
 #include "getlopt.h"
 #include "buffer.h"
@@ -223,7 +227,7 @@
 {
     int loop, rannum;
 
-    srand(time(NULL));
+    srandomdev();
     if(shuffleord)
       free(shuffleord);
     shuffleord = (int *) malloc((numfiles + 1) * sizeof(int));
@@ -239,7 +243,7 @@
     /* now shuffle them */
     if(numfiles >= 2) {
       for (loop = 0; loop < numfiles; loop++) {
-	rannum = (rand() % (numfiles * 4 - 4)) / 4;
+	rannum = (random() % (numfiles * 4 - 4)) / 4;
         rannum += (rannum >= loop);
 	shuffleord[loop] ^= shuffleord[rannum];
 	shuffleord[rannum] ^= shuffleord[loop];
@@ -381,7 +385,7 @@
         curfile++;
     }
     else {
-       newfile = shufflist[ rand() % shuffle_listsize ];
+       newfile = shufflist[ random() % shuffle_listsize ];
     }
 
     return newfile;
@@ -605,6 +609,9 @@
 		}
 
 		if(fr->header_change > 1 || init) {
+
+			init_output();
+
 			old_rate = ai.rate;
 			old_format = ai.format;
 			old_channels = ai.channels;
@@ -652,7 +659,6 @@
 					break;
 			}
 
-			init_output();
 			if(ai.rate != old_rate || ai.channels != old_channels ||
 			   ai.format != old_format || param.force_reopen) {
 				if(param.force_mono < 0) {
@@ -787,6 +793,10 @@
         _wildcard(&argc,&argv);
 #endif
 
+#ifdef __FreeBSD__
+	fpsetmask(0);
+#endif
+
 	if(sizeof(short) != 2) {
 		fprintf(stderr,"Ouch SHORT has size of %d bytes (required: '2')\n",(int)sizeof(short));
 		exit(1);
@@ -923,17 +933,6 @@
 				&dirname, &filename))
 				fprintf(stderr, "\nDirectory: %s", dirname);
 			fprintf(stderr, "\nPlaying MPEG stream from %s ...\n", filename);
-
-#if !defined(GENERIC)
-{
-     const char *term_type;
-         term_type = getenv("TERM");
-         if (!strcmp(term_type,"xterm"))
-         {
-           fprintf(stderr, "\033]0;%s\007", filename);
-         }
-}
-#endif
 
 		}
 
