qemu/hw/audio
Volker Rümelin a7a2570f22 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 74e8593e7e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-12-20 19:11:10 +03:00
..
ac97.c hw/audio/ac97: Remove unneeded local variables 2022-05-25 21:26:35 +02:00
adlib.c hw/audio/adlib: Remove unused variable in adlib_callback 2021-07-26 07:07:07 -10:00
cs4231.c hw: Replace anti-social QOM type names 2021-03-19 15:18:43 +01:00
cs4231a.c hw/audio/cs4231a: Const'ify global tables 2022-06-11 11:44:50 +02:00
es1370.c hw/audio/es1370: reset current sample counter 2023-10-21 14:05:14 +03:00
fmopl.c hw/audio/fmopl: fix segmentation fault 2020-03-25 09:55:40 +01:00
fmopl.h fmops: fix off-by-one in AR_TABLE and DR_TABLE array size 2018-11-26 11:15:32 +01:00
gus.c hw/isa: Inline and remove one-line isa_init_irq() 2022-03-08 19:38:17 +01:00
gusemu_hal.c hw/audio/gus: Fix registers 32-bit access 2020-06-19 11:20:09 +02:00
gusemu_mixer.c hw/audio/gus: Fix registers 32-bit access 2020-06-19 11:20:09 +02:00
gusemu.h audio: GUSsample is int16_t 2017-05-04 09:16:05 +02:00
gustate.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
hda-codec-common.h hda-codec: make mixemu selectable at runtime 2013-09-24 10:29:34 +02:00
hda-codec.c hw/audio/hda-codec: fix multiplication overflow 2023-12-20 19:11:10 +03:00
intel-hda-defs.h hw: move private headers to hw/ subdirectories. 2013-04-08 18:13:16 +02:00
intel-hda.c hw/audio/intel-hda: Drop unnecessary prototype 2022-11-23 12:30:45 +01:00
intel-hda.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
Kconfig hw: Move MARVELL_88W8618 Kconfig from audio/ to arm/ 2022-01-20 11:47:52 +00:00
lm4549.c Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
lm4549.h Include exec/memory.h slightly less 2019-08-16 13:31:52 +02:00
marvell_88w8618.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
meson.build Drop the deprecated lm32 target 2021-05-12 18:20:25 +02:00
pcspk.c pc: remove -soundhw pcspk 2022-05-07 07:46:59 +02:00
pl041.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
pl041.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
pl041.hx hw: move target-independent files to subdirectories 2013-04-08 18:13:12 +02:00
sb16.c hw/isa: Inline and remove one-line isa_init_irq() 2022-03-08 19:38:17 +01:00
soundhw.c introduce -audio as a replacement for -soundhw 2022-05-14 12:33:44 +02:00
trace-events docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
via-ac97.c audio/via-ac97: Simplify code and set user_creatable to false 2021-01-04 23:24:44 +01:00
wm8750.c Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00