[Midnightbsd-cvs] CVS Commit: dev/speaker: Speaker duration is incorrect according to the

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Aug 11 23:04:39 EDT 2007


Log Message:
-----------
Speaker duration is incorrect according to the documentation.  Fix this.

$MidnightBSD$

Modified Files:
--------------
    src/sys/dev/speaker:
        speaker.h (r1.1.1.1 -> r1.2)
        spkr.c (r1.1.1.1 -> r1.2)

-------------- next part --------------
Index: spkr.c
===================================================================
RCS file: /home/cvs/src/sys/dev/speaker/spkr.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -Lsys/dev/speaker/spkr.c -Lsys/dev/speaker/spkr.c -u -r1.1.1.1 -r1.2
--- sys/dev/speaker/spkr.c
+++ sys/dev/speaker/spkr.c
@@ -4,10 +4,12 @@
  * v1.4 by Eric S. Raymond (esr at snark.thyrsus.com) Aug 1993
  * modified for FreeBSD by Andrew A. Chernov <ache at astral.msk.su>
  * modified for PC98 by Kakefuda
+ *
+ * $MidnightBSD$
+ * $FreeBSD: src/sys/dev/speaker/spkr.c,v 1.70.2.1 2005/11/16 10:50:11 ru Exp $
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/speaker/spkr.c,v 1.70.2.1 2005/11/16 10:50:11 ru Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,19 +65,19 @@
 #define SPKRPRI PSOCK
 static char endtone, endrest;
 
-static void tone(unsigned int thz, unsigned int ticks);
-static void rest(int ticks);
+static void tone(unsigned int thz, unsigned int centisecs);
+static void rest(int centisecs);
 static void playinit(void);
 static void playtone(int pitch, int value, int sustain);
 static void playstring(char *cp, size_t slen);
 
-/* emit tone of frequency thz for given number of ticks */
+/* emit tone of frequency thz for given number of centisecs */
 static void
-tone(thz, ticks)
-	unsigned int thz, ticks;
+tone(thz, centisecs)
+	unsigned int thz, centisecs;
 {
     unsigned int divisor;
-    int sps;
+    int sps, timo;
 
     if (thz <= 0)
 	return;
@@ -83,7 +85,7 @@
     divisor = timer_freq / thz;
 
 #ifdef DEBUG
-    (void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
+    (void) printf("tone: thz=%d centisecs=%d\n", thz, centisecs);
 #endif /* DEBUG */
 
     /* set timer to generate clicks at given frequency in Hertz */
@@ -107,29 +109,33 @@
      * This is so other processes can execute while the tone is being
      * emitted.
      */
-    if (ticks > 0)
-	tsleep(&endtone, SPKRPRI | PCATCH, "spkrtn", ticks);
+    timo = centisecs * hz / 100;
+    if (timo > 0)
+	tsleep(&endtone, SPKRPRI | PCATCH, "spkrtn", timo);
     ppi_spkr_off();
     sps = splclock();
     timer_spkr_release();
     splx(sps);
 }
 
-/* rest for given number of ticks */
+/* rest for given number of centisecs */
 static void
-rest(ticks)
-	int	ticks;
+rest(centisecs)
+	int	centisecs;
 {
+    int timo;
+
     /*
      * Set timeout to endrest function, then give up the timeslice.
      * This is so other processes can execute while the rest is being
      * waited out.
      */
 #ifdef DEBUG
-    (void) printf("rest: %d\n", ticks);
+    (void) printf("rest: %d\n", centisecs);
 #endif /* DEBUG */
-    if (ticks > 0)
-	tsleep(&endrest, SPKRPRI | PCATCH, "spkrrs", ticks);
+    timo = centisecs * hz / 100;
+    if (timo > 0)
+	tsleep(&endrest, SPKRPRI | PCATCH, "spkrrs", timo);
 }
 
 /**************** PLAY STRING INTERPRETER BEGINS HERE **********************
@@ -197,7 +203,7 @@
 playinit()
 {
     octave = DFLT_OCTAVE;
-    whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
+    whole = (100 * SECS_PER_MIN * WHOLE_NOTE) / DFLT_TEMPO;
     fill = NORMAL;
     value = DFLT_VALUE;
     octtrack = FALSE;
@@ -406,7 +412,7 @@
 	    GETNUM(cp, tempo);
 	    if (tempo < MIN_TEMPO || tempo > MAX_TEMPO)
 		tempo = DFLT_TEMPO;
-	    whole = (hz * SECS_PER_MIN * WHOLE_NOTE) / tempo;
+	    whole = (100 * SECS_PER_MIN * WHOLE_NOTE) / tempo;
 	    break;
 
 	case 'M':
Index: speaker.h
===================================================================
RCS file: /home/cvs/src/sys/dev/speaker/speaker.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -Lsys/dev/speaker/speaker.h -Lsys/dev/speaker/speaker.h -u -r1.1.1.1 -r1.2
--- sys/dev/speaker/speaker.h
+++ sys/dev/speaker/speaker.h
@@ -4,6 +4,7 @@
  * v1.4 by Eric S. Raymond (esr at snark.thyrsus.com) Aug 1993
  *      modified for FreeBSD by Andrew A. Chernov <ache at astral.msk.su>
  *
+ * $MidnightBSD$
  * $FreeBSD: src/sys/dev/speaker/speaker.h,v 1.8.2.1 2005/11/16 10:50:11 ru Exp $
  */
 


More information about the Midnightbsd-cvs mailing list