From patchwork Wed Apr 1 19:00:15 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: 1265316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=t-online.de 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 ozlabs.org (Postfix) with ESMTPS id 48swY75Xybz9sPF for ; Thu, 2 Apr 2020 06:02:03 +1100 (AEDT) Received: from localhost ([::1]:36112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJicj-0001jc-LN for incoming@patchwork.ozlabs.org; Wed, 01 Apr 2020 15:02:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58555) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJib9-0000RW-2c for qemu-devel@nongnu.org; Wed, 01 Apr 2020 15:00:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJib7-0002R8-On for qemu-devel@nongnu.org; Wed, 01 Apr 2020 15:00:22 -0400 Received: from mailout11.t-online.de ([194.25.134.85]:47022) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJib7-0002Pp-HQ for qemu-devel@nongnu.org; Wed, 01 Apr 2020 15:00:21 -0400 Received: from fwd05.aul.t-online.de (fwd05.aul.t-online.de [172.20.27.149]) by mailout11.t-online.de (Postfix) with SMTP id 8A14A421358D; Wed, 1 Apr 2020 21:00:19 +0200 (CEST) Received: from linpower.localnet (rALmjkZE8hMODYjB4Ths8Dg1ROJWkeEYp2UEijwuIQ1eGy98fhyBR3sTOGZcZXmQN-@[93.236.147.242]) by fwd05.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1jJib4-3IemmW0; Wed, 1 Apr 2020 21:00:18 +0200 Received: by linpower.localnet (Postfix, from userid 1000) id 58307200467; Wed, 1 Apr 2020 21:00:17 +0200 (CEST) From: =?utf-8?q?Volker_R=C3=BCmelin?= To: Gerd Hoffmann Subject: [PATCH 1/3] dsoundaudio: fix never-ending playback loop Date: Wed, 1 Apr 2020 21:00:15 +0200 Message-Id: <20200401190017.5081-1-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: rALmjkZE8hMODYjB4Ths8Dg1ROJWkeEYp2UEijwuIQ1eGy98fhyBR3sTOGZcZXmQN- X-TOI-MSGID: 7d63d7ff-393a-48e6-b261-cf42a18260c8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 194.25.134.85 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently the DirectSound backend fails to stop audio playback in dsound_enable_out(). The call to IDirectSoundBuffer_GetStatus() in dsound_get_status_out() returns a status word with the flag DSERR_BUFFERLOST set (probably because of a buffer underrun). The function dsound_get_status_out() correctly calls dsound_restore_out() and returns an error. This is wrong. If dsound_restore_out() succeeds the program should continue without an error. To reproduce the bug start qemu on a Windows host with -soundhw pcspk -audiodev dsound,id=audio0. On the guest FreeDOS 1.2 command line enter beep. The image Day 1 - F-Bird from the QEMU Advent Calendar 2018 shows the bug as well. Fixes: 2762955f72 "dsoundaudio: remove *_retries kludges" Buglink: https://bugs.launchpad.net/qemu/+bug/1699628 Signed-off-by: Volker RĂ¼melin --- audio/dsoundaudio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c index bd57082a8d..af70dd128e 100644 --- a/audio/dsoundaudio.c +++ b/audio/dsoundaudio.c @@ -280,8 +280,10 @@ static int dsound_get_status_out (LPDIRECTSOUNDBUFFER dsb, DWORD *statusp, } if (*statusp & DSERR_BUFFERLOST) { - dsound_restore_out(dsb, s); - return -1; + if (dsound_restore_out(dsb, s)) { + return -1; + } + *statusp &= ~DSERR_BUFFERLOST; } return 0;