diff options
| author | Brian Somers <brian@FreeBSD.org> | 2007-07-12 07:05:43 +0000 |
|---|---|---|
| committer | Brian Somers <brian@FreeBSD.org> | 2007-07-12 07:05:43 +0000 |
| commit | eb3554617490f8c1387ef3150c96231651987eee (patch) | |
| tree | 4d874ccf7d7354109d9b4e320df7483dcec94e88 /sys/dev/speaker | |
| parent | 36dba09d678a3027e4f2feff32030293d813972d (diff) | |
Notes
Diffstat (limited to 'sys/dev/speaker')
| -rw-r--r-- | sys/dev/speaker/spkr.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index bad65c15eff0..4ab065e19243 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -63,19 +63,19 @@ static MALLOC_DEFINE(M_SPKR, "spkr", "Speaker buffer"); #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 +83,7 @@ tone(thz, ticks) 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 +107,33 @@ tone(thz, ticks) * 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 +201,7 @@ static void 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 +410,7 @@ playstring(cp, slen) 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': |
