diff mbox series

[1/3] dsoundaudio: fix never-ending playback loop

Message ID 20200401190017.5081-1-vr_qemu@t-online.de
State New
Headers show
Series DirectSound fixes for 5.0 | expand

Commit Message

Volker RĂ¼melin April 1, 2020, 7 p.m. UTC
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 <vr_qemu@t-online.de>
---
 audio/dsoundaudio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

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;