summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-11-06 00:52:36 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-06-17 23:50:19 +0200
commitc5cf4c634ca3bd85bd9ea32142359fc254ec54e4 (patch)
tree321dd3585e1d61aa2e01de82850a3d2c32f6a92d
parent9deef0690a85035caa08b6d58032c89903c476f0 (diff)
2002-11-05 Roland McGrath <roland@frob.com>
* oskit/pc/osenv_bell.c (direct_cons_bell): Use a private timer instead of calling `timeout'. If a bell is already ringing, turn it off for an instant before setting the new one.
-rw-r--r--oskit/pc/osenv_bell.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/oskit/pc/osenv_bell.c b/oskit/pc/osenv_bell.c
index 3e6b44ec..86c5b78a 100644
--- a/oskit/pc/osenv_bell.c
+++ b/oskit/pc/osenv_bell.c
@@ -6,12 +6,22 @@
#include "time_out.h"
-
#define BELL_FREQUENCY 750 /* Hz */
+#define BELL_DURATION (hz>>3) /* 1/8th second duration */
+
+/* This is the private timer used to turn off the speaker. */
+static timer_elt_data_t bell_timer = { fcn: (int (*)()) &pc_speaker_off };
void
-direct_cons_bell(void)
+direct_cons_bell (void)
{
+ /* Cancel the timeout for a bell we are already ringing. */
+ if (reset_timeout (&bell_timer))
+ /* Turn the speaker off for an instant to distinguish this bell
+ from the next. */
+ pc_speaker_off ();
+
+ /* Turn the speaker on and set the timeout to turn it off. */
pc_speaker_on (BELL_FREQUENCY);
- timeout (&pc_speaker_off, 0, hz / 8); /* 1/8th second duration */
+ set_timeout (&bell_timer, BELL_DURATION);
}