aboutsummaryrefslogtreecommitdiff
path: root/audio/audio.c
diff options
context:
space:
mode:
authorVolker Rümelin <vr_qemu@t-online.de>2022-09-23 20:36:39 +0200
committerGerd Hoffmann <kraxel@redhat.com>2022-10-11 10:17:08 +0200
commitb73ef11ff68f05418c8b60945b1e1783a72bd822 (patch)
tree592b6c42393f1bb795b9c1edeb8b33907ba88da4 /audio/audio.c
parent0724c57988f4ad826b02f12093ace5ef657cec21 (diff)
downloadqemu-b73ef11ff68f05418c8b60945b1e1783a72bd822.zip
qemu-b73ef11ff68f05418c8b60945b1e1783a72bd822.tar.gz
qemu-b73ef11ff68f05418c8b60945b1e1783a72bd822.tar.bz2
audio: fix sw->buf size for audio recording
The calculation of the buffer size needed to store audio samples after resampling is wrong for audio recording. For audio recording sw->ratio is calculated as sw->ratio = frontend sample rate / backend sample rate. From this follows frontend samples = frontend sample rate / backend sample rate * backend samples frontend samples = sw->ratio * backend samples In 2 of 3 places in the audio recording code where sw->ratio is used in a calculation to get the number of frontend frames, the calculation is wrong. Fix this. The 3rd formula in audio_pcm_sw_read() is correct. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/71 Signed-off-by: Volker Rümelin <vr_qemu@t-online.de> Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220923183640.8314-11-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/audio.c')
-rw-r--r--audio/audio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/audio/audio.c b/audio/audio.c
index ed2b9d5..8867257 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -995,7 +995,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on)
*/
static size_t audio_frontend_frames_in(SWVoiceIn *sw, size_t frames_in)
{
- return ((int64_t)frames_in << 32) / sw->ratio;
+ return (int64_t)frames_in * sw->ratio >> 32;
}
static size_t audio_get_avail (SWVoiceIn *sw)