diff options
author | malc <av1474@comtv.ru> | 2009-09-18 08:16:03 +0400 |
---|---|---|
committer | malc <av1474@comtv.ru> | 2009-09-18 14:04:36 +0400 |
commit | 4f4cc0efde875ec9fce206c365597878fc4921e7 (patch) | |
tree | b57773b376d9ee7c2b8071847f05c59e1ab78293 | |
parent | coreaudio: fix sloppy "posixification" by 1ea879e5580f63414693655fcf0328559cd... (diff) | |
download | qemu-kvm-4f4cc0efde875ec9fce206c365597878fc4921e7.tar.gz qemu-kvm-4f4cc0efde875ec9fce206c365597878fc4921e7.tar.bz2 qemu-kvm-4f4cc0efde875ec9fce206c365597878fc4921e7.zip |
audio: use muldiv64 where it makes sense
Signed-off-by: malc <av1474@comtv.ru>
-rw-r--r-- | audio/audio.c | 3 | ||||
-rw-r--r-- | audio/audio_template.h | 2 | ||||
-rw-r--r-- | audio/noaudio.c | 5 | ||||
-rw-r--r-- | audio/wavaudio.c | 3 | ||||
-rw-r--r-- | hw/gus.c | 4 | ||||
-rw-r--r-- | hw/sb16.c | 4 |
6 files changed, 12 insertions, 9 deletions
diff --git a/audio/audio.c b/audio/audio.c index d8e54961f..a3e23b212 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -1878,7 +1878,8 @@ static void audio_init (void) } conf.period.ticks = 1; } else { - conf.period.ticks = get_ticks_per_sec() / conf.period.hertz; + conf.period.ticks = + muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); } e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); diff --git a/audio/audio_template.h b/audio/audio_template.h index e65d834ac..70c4a8818 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -556,7 +556,7 @@ uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts) return 0; } - return (delta * sw->hw->info.freq) / 1000000; + return muldiv64 (delta, sw->hw->info.freq, 1000000); } #undef TYPE diff --git a/audio/noaudio.c b/audio/noaudio.c index 2f25f176e..82272b719 100644 --- a/audio/noaudio.c +++ b/audio/noaudio.c @@ -53,7 +53,7 @@ static int no_run_out (HWVoiceOut *hw) now = qemu_get_clock (vm_clock); ticks = now - no->old_ticks; - bytes = (ticks * hw->info.bytes_per_second) / get_ticks_per_sec(); + bytes = muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ()); bytes = audio_MIN (bytes, INT_MAX); samples = bytes >> hw->info.shift; @@ -109,7 +109,8 @@ static int no_run_in (HWVoiceIn *hw) if (dead) { int64_t now = qemu_get_clock (vm_clock); int64_t ticks = now - no->old_ticks; - int64_t bytes = (ticks * hw->info.bytes_per_second) / get_ticks_per_sec(); + int64_t bytes = + muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ()); no->old_ticks = now; bytes = audio_MIN (bytes, INT_MAX); diff --git a/audio/wavaudio.c b/audio/wavaudio.c index 78eb758bd..e659aa541 100644 --- a/audio/wavaudio.c +++ b/audio/wavaudio.c @@ -54,7 +54,8 @@ static int wav_run_out (HWVoiceOut *hw) struct st_sample *src; int64_t now = qemu_get_clock (vm_clock); int64_t ticks = now - wav->old_ticks; - int64_t bytes = (ticks * hw->info.bytes_per_second) / get_ticks_per_sec(); + int64_t bytes = + muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ()); if (bytes > INT_MAX) { samples = INT_MAX >> hw->info.shift; @@ -156,8 +156,8 @@ static void GUS_callback (void *opaque, int free) } s->left = samples; -reset: - gus_irqgen (&s->emu, (double) (net * 1000000) / s->freq); + reset: + gus_irqgen (&s->emu, muldiv64 (net, 1000000, s->freq)); } int GUS_irqrequest (GUSEmuState *emu, int hwirq, int n) @@ -758,8 +758,8 @@ static void complete (SB16State *s) freq = s->freq > 0 ? s->freq : 11025; samples = dsp_get_lohi (s) + 1; bytes = samples << s->fmt_stereo << (s->fmt_bits == 16); - ticks = (bytes * get_ticks_per_sec()) / freq; - if (ticks < get_ticks_per_sec() / 1024) { + ticks = muldiv64 (bytes, get_ticks_per_sec (), freq); + if (ticks < get_ticks_per_sec () / 1024) { qemu_irq_raise (s->pic); } else { |