]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
dsoundaudio: dsound_get_buffer_in should honor *size
authorVolker Rümelin <vr_qemu@t-online.de>
Sun, 5 Apr 2020 07:50:17 +0000 (09:50 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 6 Apr 2020 11:29:53 +0000 (13:29 +0200)
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>
audio/audio.c
audio/dsoundaudio.c

index 9ac9a20c41bacae49ee55ae1b22ab90cab1ae670..7a9e6803558b85ff8d4158aa35f9427d9daa56d4 100644 (file)
@@ -1491,15 +1491,13 @@ size_t audio_generic_write(HWVoiceOut *hw, void *buf, size_t size)
 
 size_t audio_generic_read(HWVoiceIn *hw, void *buf, size_t size)
 {
-    size_t src_size, copy_size;
-    void *src = hw->pcm_ops->get_buffer_in(hw, &src_size);
-    copy_size = MIN(size, src_size);
+    void *src = hw->pcm_ops->get_buffer_in(hw, &size);
 
-    memcpy(buf, src, copy_size);
-    hw->pcm_ops->put_buffer_in(hw, src, copy_size);
-    return copy_size;
-}
+    memcpy(buf, src, size);
+    hw->pcm_ops->put_buffer_in(hw, src, size);
 
+    return size;
+}
 
 static int audio_driver_init(AudioState *s, struct audio_driver *drv,
                              bool msg, Audiodev *dev)
index a08d519cae6ad8d4895543a211cc6c3735aebeee..4cdf19ab6799f632e093d03f01c432d7d32b1162 100644 (file)
@@ -540,7 +540,7 @@ static void *dsound_get_buffer_in(HWVoiceIn *hw, size_t *size)
     }
 
     req_size = audio_ring_dist(cpos, hw->pos_emul, hw->size_emul);
-    req_size = MIN(req_size, hw->size_emul - hw->pos_emul);
+    req_size = MIN(*size, MIN(req_size, hw->size_emul - hw->pos_emul));
 
     if (req_size == 0) {
         *size = 0;