From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Volker Rümelin" <vr_qemu@t-online.de>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PULL 3/4] dsoundaudio: dsound_get_buffer_in should honor *size
Date: Tue, 7 Apr 2020 11:22:05 +0200 [thread overview]
Message-ID: <20200407092207.6079-4-kraxel@redhat.com> (raw)
In-Reply-To: <20200407092207.6079-1-kraxel@redhat.com>
From: Volker Rümelin <vr_qemu@t-online.de>
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 | 12 +++++-------
audio/dsoundaudio.c | 2 +-
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/audio/audio.c b/audio/audio.c
index 9ac9a20c41ba..7a9e6803558b 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1491,16 +1491,14 @@ 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)
{
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index a08d519cae6a..4cdf19ab6799 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -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;
--
2.18.2
next prev parent reply other threads:[~2020-04-07 9:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 9:22 [PULL 0/4] Fixes 20200407 patches Gerd Hoffmann
2020-04-07 9:22 ` [PULL 1/4] dsoundaudio: fix never-ending playback loop Gerd Hoffmann
2020-04-07 9:22 ` [PULL 2/4] dsoundaudio: fix "Could not lock capture buffer" warning Gerd Hoffmann
2020-04-07 9:22 ` Gerd Hoffmann [this message]
2020-04-07 9:22 ` [PULL 4/4] ati-vga: Fix checks in ati_2d_blt() to avoid crash Gerd Hoffmann
2020-04-07 14:09 ` [PULL 0/4] Fixes 20200407 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200407092207.6079-4-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vr_qemu@t-online.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).