diff options
author | Volker RĂ¼melin | 2021-12-26 16:40:16 +0100 |
---|---|---|
committer | Gerd Hoffmann | 2022-01-13 10:47:52 +0100 |
commit | 9d90ceb27461d7d0d172fd941b812d511794a6c6 (patch) | |
tree | b95b25f7d550ea4970a6522e0eb9afbe83e82ae1 /audio | |
parent | jackaudio: use ifdefs to hide unavailable functions (diff) | |
download | qemu-9d90ceb27461d7d0d172fd941b812d511794a6c6.tar.gz qemu-9d90ceb27461d7d0d172fd941b812d511794a6c6.tar.xz qemu-9d90ceb27461d7d0d172fd941b812d511794a6c6.zip |
dsoundaudio: fix crackling audio recordings
Audio recordings with the DirectSound backend don't sound right.
A look a the Microsoft online documentation tells us why.
From the DirectSound Programming Guide, Capture Buffer Information:
'You can safely copy data from the buffer only up to the read
cursor.'
Change the code to read up to the read cursor instead of the
capture cursor.
Signed-off-by: Volker RĂ¼melin <vr_qemu@t-online.de>
Message-Id: <20211226154017.6067-2-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio')
-rw-r--r-- | audio/dsoundaudio.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index cfc79c129e..3dd2c4d4a6 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -536,13 +536,12 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size) DSoundVoiceIn *ds = (DSoundVoiceIn *) hw; LPDIRECTSOUNDCAPTUREBUFFER dscb = ds->dsound_capture_buffer; HRESULT hr; - DWORD cpos, rpos, act_size; + DWORD rpos, act_size; size_t req_size; int err; void *ret; - hr = IDirectSoundCaptureBuffer_GetCurrentPosition( - dscb, &cpos, ds->first_time ? &rpos : NULL); + hr = IDirectSoundCaptureBuffer_GetCurrentPosition(dscb, NULL, &rpos); if (FAILED(hr)) { dsound_logerr(hr, "Could not get capture buffer position\n"); *size = 0; @@ -554,7 +553,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size) ds->first_time = false; } - req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul); + req_size = audio_ring_dist(rpos, hw->pos_emul, hw->size_emul); req_size = MIN(*size, MIN(req_size, hw->size_emul - hw->pos_emul)); if (req_size == 0) { |