mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
audio: use muldiv64 where it makes sense
Signed-off-by: malc <av1474@comtv.ru>
This commit is contained in:
parent
68f6dc7ebd
commit
4f4cc0efde
6 changed files with 12 additions and 9 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue