qemu/hw/audio
Volker Rümelin 59de6e246f hw/audio/hda-codec: fix multiplication overflow
After a relatively short time, there is an multiplication overflow
when multiplying (now - buft_start) with hda_bytes_per_second().
While the uptime now - buft_start only overflows after 2**63 ns
= 292.27 years, this happens hda_bytes_per_second() times faster
with the multiplication. At 44100 samples/s * 2 channels
* 2 bytes/channel = 176400 bytes/s that is 14.52 hours. After the
multiplication overflow the affected audio stream stalls.

Replace the multiplication and following division with muldiv64()
to prevent a multiplication overflow.

Fixes: 280c1e1cdb ("audio/hda: create millisecond timers that handle IO")
Reported-by: M_O_Bz <m_o_bz@163.com>
Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-Id: <20231105172552.8405-1-vr_qemu@t-online.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 74e8593e7e51d6b11ae9c56a3f4e7bb714bac4ec)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-12-05 12:32:36 +03:00
..
ac97.c hw/audio/ac97: Split off some definitions to a header 2023-02-27 22:29:02 +01:00
ac97.h hw/audio/ac97: Split off some definitions to a header 2023-02-27 22:29:02 +01:00
adlib.c
cs4231.c
cs4231a.c hw: Replace isa_get_irq() by isa_bus_get_irq() when ISABus is available 2023-02-27 22:29:02 +01:00
es1370.c hw/audio/es1370: reset current sample counter 2023-10-12 01:10:13 +03:00
fmopl.c
fmopl.h
gus.c hw: Replace isa_get_irq() by isa_bus_get_irq() when ISABus is available 2023-02-27 22:29:02 +01:00
gusemu.h
gusemu_hal.c
gusemu_mixer.c
gustate.h
hda-codec-common.h
hda-codec.c hw/audio/hda-codec: fix multiplication overflow 2023-12-05 12:32:36 +03:00
intel-hda-defs.h
intel-hda.c
intel-hda.h
Kconfig
lm4549.c
lm4549.h
marvell_88w8618.c
meson.build meson: Replace softmmu_ss -> system_ss 2023-06-20 10:01:30 +02:00
pcspk.c
pl041.c
pl041.h
pl041.hx
sb16.c hw: Replace isa_get_irq() by isa_bus_get_irq() when ISABus is available 2023-02-27 22:29:02 +01:00
soundhw.c
trace-events hw/audio/via-ac97: Basic implementation of audio playback 2023-03-08 00:37:48 +01:00
trace.h
via-ac97.c hw/audio/via-ac97: Basic implementation of audio playback 2023-03-08 00:37:48 +01:00
wm8750.c