patch-1.3.9 linux/drivers/sound/sys_timer.c
Next file: linux/drivers/sound/trix.c
Previous file: linux/drivers/sound/sscape.c
Back to the patch index
Back to the overall index
- Lines: 29
- Date:
Mon Jul 10 01:45:23 1995
- Orig file:
v1.3.8/linux/drivers/sound/sys_timer.c
- Orig date:
Mon Jul 18 09:50:55 1994
diff -u --recursive --new-file v1.3.8/linux/drivers/sound/sys_timer.c linux/drivers/sound/sys_timer.c
@@ -51,17 +51,23 @@
tmr2ticks (int tmr_value)
{
/*
- * Convert system timer ticks (HZ) to MIDI ticks
- */
+ * Convert system timer ticks (HZ) to MIDI ticks
+ */
unsigned long tmp;
unsigned long scale;
- tmp = (tmr_value * 1000) / HZ;/* Convert to msecs */
+ tmp = (tmr_value * 1000) / HZ; /* Convert to msecs */
- scale = (60 * 1000) / (curr_tempo * curr_timebase); /* msecs per MIDI tick */
+ if (curr_tempo == 0 || curr_timebase == 0) /* Error? */
+ scale = 1;
+ else
+ scale = (60 * 1000) / (curr_tempo * curr_timebase); /* msecs per MIDI tick */
- return (tmp + (scale / 2)) / scale;
+ if (scale == 0) /* Error? */
+ scale = 1;
+
+ return (tmp + (scale >> 1)) / scale;
}
static void
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this