qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

dsoundaudio: dsound_get_buffer_in should honor *size

This patch prevents an underflow of variable samples in function
audio_pcm_hw_run_in(). See commit 599eac4e5a "audio:
audio_generic_get_buffer_in should honor *size". This time the
while loop in audio_pcm_hw_run_in() will terminate nevertheless,
because it seems the recording stream in Windows is always rate
limited.

Signed-off-by: Volker Rümelin <vr_qemu@t-online.de>
Message-id: 20200405075017.9901-3-vr_qemu@t-online.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

authored by

Volker Rümelin and committed by
Gerd Hoffmann
8d1439b6 17470298

+6 -8
+5 -7
audio/audio.c
··· 1491 1491 1492 1492 size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size) 1493 1493 { 1494 - size_t src_size, copy_size; 1495 - void *src = hw->pcm_ops->get_buffer_in(hw, &src_size); 1496 - copy_size = MIN(size, src_size); 1494 + void *src = hw->pcm_ops->get_buffer_in(hw, &size); 1497 1495 1498 - memcpy(buf, src, copy_size); 1499 - hw->pcm_ops->put_buffer_in(hw, src, copy_size); 1500 - return copy_size; 1501 - } 1496 + memcpy(buf, src, size); 1497 + hw->pcm_ops->put_buffer_in(hw, src, size); 1502 1498 1499 + return size; 1500 + } 1503 1501 1504 1502 static int audio_driver_init(AudioState *s, struct audio_driver *drv, 1505 1503 bool msg, Audiodev *dev)
+1 -1
audio/dsoundaudio.c
··· 540 540 } 541 541 542 542 req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul); 543 - req_size = MIN(req_size, hw->size_emul - hw->pos_emul); 543 + req_size = MIN(*size, MIN(req_size, hw->size_emul - hw->pos_emul)); 544 544 545 545 if (req_size == 0) { 546 546 *size = 0;