From patchwork Wed Apr 1 19:00:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Volker_R=C3=BCmelin?= X-Patchwork-Id: 11469473 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AACBD159A for ; Wed, 1 Apr 2020 19:01:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8A226206EB for ; Wed, 1 Apr 2020 19:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A226206EB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:36116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJicY-0002Ak-Kt for patchwork-qemu-devel@patchwork.kernel.org; Wed, 01 Apr 2020 15:01:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJibC-0000VI-B9 for qemu-devel@nongnu.org; Wed, 01 Apr 2020 15:00:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJibB-0002Su-Ai for qemu-devel@nongnu.org; Wed, 01 Apr 2020 15:00:26 -0400 Received: from mailout05.t-online.de ([194.25.134.82]:45920) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJibB-0002S9-3g for qemu-devel@nongnu.org; Wed, 01 Apr 2020 15:00:25 -0400 Received: from fwd24.aul.t-online.de (fwd24.aul.t-online.de [172.20.26.129]) by mailout05.t-online.de (Postfix) with SMTP id AB4E54204FD2; Wed, 1 Apr 2020 21:00:23 +0200 (CEST) Received: from linpower.localnet (S34u6qZerhlO6FMPJtsDHXL87lBI2i71ZdMmE3iDMAAMz2+EcWnhWJlBOMO7ls1QPS@[93.236.147.242]) by fwd24.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jJib9-12XGeO0; Wed, 1 Apr 2020 21:00:23 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 5B4C5200F43; Wed, 1 Apr 2020 21:00:17 +0200 (CEST) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 3/3] dsoundaudio: dsound_get_buffer_in should honor *size Date: Wed, 1 Apr 2020 21:00:17 +0200 Message-Id: <20200401190017.5081-3-vr_qemu@t-online.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <19cd6a5a-97b7-b684-f026-11d82e34dab9@t-online.de> References: <19cd6a5a-97b7-b684-f026-11d82e34dab9@t-online.de> MIME-Version: 1.0 X-ID: S34u6qZerhlO6FMPJtsDHXL87lBI2i71ZdMmE3iDMAAMz2+EcWnhWJlBOMO7ls1QPS X-TOI-MSGID: 20c42069-0717-44d3-85bc-edd298cc8e74 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.82 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QEMU , =?utf-8?b?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 9ac9a20c41..7a9e680355 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -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) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index ea1595dcd1..d3522f0e00 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -542,7 +542,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;